HTM SpatialIndex Class Reference

class BitListIterator

BitListIterator class

Public Methods

BitListIterator ()
Default Constructor.
BitListIterator (const BitList & bitlist)
Normal Constructor
BitListIterator (const BitList & bitlist, size_t start)
Alternate constructor
BitListIterator (const BitListIterator &)
Copy Constructor.
BitListIterator& operator = (const BitListIterator &)
Assignment.
void setindex (size_t index)
Init: set current index
bool next (bool bit, size_t & _index)
Set the internal index to the next 'true' or 'false' bit; indicated by the first argument, and return the index in the second argument
bool prev (bool bit, size_t & _index)
Just like next(), but the index is moved backwards.
bool next (bool & bit)
Increment the internal index and return the value of the bit it points to Returns 'false' if the boundary is reached
bool prev (bool & bit)
Just like next() above, just decrement the internal index

Documentation

BitListIterator class. The BitListIterator iterates through a BitList efficiently. next() and prev() functions are supplied. The functionality is the following: The BLI saves an index to a certain bit in the BitList. By calling either next() or prev(), the index is incremented/decremented and the bit it is pointing to now is returned. If it gets out of bounds, these functions return 'false'. The out-of-bounds index is always index=size. So by calling next() or prev() again when a 'false' was returned previously, they return the first/last bit, respectively.
BitListIterator()
Default Constructor.

BitListIterator(const BitList & bitlist)
Normal Constructor. needs the BitList to initialize. The index is initialized to the out-of-bounds index.

BitListIterator(const BitList & bitlist, size_t start)
Alternate constructor. set the starting index yourself.

BitListIterator(const BitListIterator &)
Copy Constructor.

BitListIterator& operator = (const BitListIterator &)
Assignment.

void setindex(size_t index)
Init: set current index

bool next(bool bit, size_t & _index)
Set the internal index to the next 'true' or 'false' bit; indicated by the first argument, and return the index in the second argument. Returns 'false' if it gets out of bounds. Example: For a BitList 001100110011 (from left to right, index starts at 0), the subsequent call to next(true,index) returns 'true' and sets index to 2, 3, 6, 7, 10, 11. The next call puts leaves index and returns 'false'. A subsequent next() call would again return 'true' and set index=2.

bool prev(bool bit, size_t & _index)
Just like next(), but the index is moved backwards.

bool next(bool & bit)
Increment the internal index and return the value of the bit it points to Returns 'false' if the boundary is reached. Example: For a BitList 001100110011 the calls to next(val) return 'true' and set bit to 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1. The next call returns 'false' and does not set bit. A subsequent call would return again 'true' and set bit to the first bit in the list, in this case 0.

bool prev(bool & bit)
Just like next() above, just decrement the internal index. The two versions of next() and prev() may be used in conjunction.


This class has no child classes.

alphabetic index hierarchy of classes


© Copyright The Johns Hopkins University 1999, All Rights Reserved.
Peter Z. Kunszt,

generated by doc++