IDSet is a BitSet allowing to generate/release IDs starting with a given start offset. More...
#include <fbitset.h>

Public Member Functions | |
| IDSet (int32 startOffset=0, int32 growSize=128) | |
| Constructor with a given starteOffset and a growing Size. | |
| int32 | newID () |
| Return a new ID (starting from the startOffset) : set the first NOT set bit to 1 and return its position added to the startOffset (resizes the bitSet if necessary). | |
| void | releaseID (int32 id) |
| Clear associated bit to the given id. | |
IDSet is a BitSet allowing to generate/release IDs starting with a given start offset.
IDSet myIDSet (100, 8); // its current size is Null int32 id1 = myIDSet.newID (); // id1 is 100 (internally bitchunk is 00000001) int32 id2 = myIDSet.newID (); // id2 is 101 (internally bitchunk is 00000011) int32 id3 = myIDSet.newID (); // id3 is 102 (internally bitchunk is 00000111) int32 id4 = myIDSet.newID (); // id4 is 103 (internally bitchunk is 00001111)myIDSet.releaseID (101); // 101 as ID is released and could be reused later (internally bitchunk is 00001101) int32 id5 = myIDSet.newID (); // id5 is 101 (internally bitchunk is 00001111) int32 id6 = myIDSet.newID (); // id6 is 104 (internally bitchunk is 00011111) int32 id7 = myIDSet.newID (); // id7 is 105 (internally bitchunk is 00111111) int32 id8 = myIDSet.newID (); // id8 is 106 (internally bitchunk is 01111111) int32 id9 = myIDSet.newID (); // id9 is 107 (internally bitchunk is 11111111) int32 id10 = myIDSet.newID (); // id10 is 108 (internally bitchunk is 00000001 11111111)
| IDSet | ( | int32 | startOffset = 0, |
|
| int32 | growSize = 128 | |||
| ) |
Constructor with a given starteOffset and a growing Size.
| int32 newID | ( | ) |
Return a new ID (starting from the startOffset) : set the first NOT set bit to 1 and return its position added to the startOffset (resizes the bitSet if necessary).
| void releaseID | ( | int32 | id | ) |
Clear associated bit to the given id.