HDK
|
Fast bit array that keeps track of the number of bits set and can find the next set in a timely manner. More...
#include <bits.h>
Classes | |
struct | FastHash |
struct | Hash |
class | View |
Public Types | |
enum | Mode { All, AllSet, AllUnset } |
using | AllView = View< All > |
using | AllSetView = View< AllSet > |
using | AllUnsetView = View< AllUnset > |
Public Member Functions | |
TfBits (size_t num=0) | |
TfBits (size_t num, size_t first, size_t last) | |
TfBits (const TfBits &rhs) | |
TfBits (TfBits &&rhs) | |
~TfBits () | |
TfBits & | operator= (const TfBits &rhs) |
TfBits & | operator= (TfBits &&rhs) |
void | Resize (size_t num) |
void | ResizeKeepContent (size_t num) |
TF_API void | OrSubset (const TfBits &rhs) |
void | Swap (TfBits &rhs) |
void | ClearAll () |
void | SetAll () |
void | Clear (size_t index) |
void | Set (size_t index) |
void | Assign (size_t index, bool val) |
bool | IsSet (size_t index) const |
size_t | FindNextSet (size_t index) const |
size_t | FindPrevSet (size_t index) const |
size_t | FindNextUnset (size_t index) const |
size_t | GetSize () const |
bool | IsEmpty () const |
size_t | GetFirstSet () const |
size_t | GetLastSet () const |
size_t | GetNumSet () const |
bool | AreAllSet () const |
bool | AreAllUnset () const |
bool | IsAnySet () const |
bool | IsAnyUnset () const |
bool | AreContiguouslySet () const |
size_t | GetAllocatedSize () const |
TF_API size_t | GetHash () const |
TF_API std::string | GetAsStringLeftToRight () const |
TF_API std::string | GetAsStringRightToLeft () const |
bool | HasNonEmptyIntersection (const TfBits &rhs) const |
bool | HasNonEmptyDifference (const TfBits &rhs) const |
bool | Contains (const TfBits &rhs) const |
AllView | GetAllView () const |
AllSetView | GetAllSetView () const |
AllUnsetView | GetAllUnsetView () const |
Operators | |
TF_API bool | operator== (const TfBits &rhs) const |
bool | operator!= (const TfBits &rhs) const |
TF_API TfBits & | operator&= (const TfBits &rhs) |
TfBits | operator& (const TfBits &rhs) const |
TF_API TfBits & | operator|= (const TfBits &rhs) |
TfBits | operator| (const TfBits &rhs) const |
TF_API TfBits & | operator^= (const TfBits &rhs) |
TfBits | operator^ (const TfBits &rhs) const |
TF_API TfBits & | operator-= (const TfBits &rhs) |
TF_API TfBits & | Complement () |
bool | operator[] (size_t index) const |
Friends | |
void | swap (TfBits &lhs, TfBits &rhs) |
Fast bit array that keeps track of the number of bits set and can find the next set in a timely manner.
Note about thread safety in this class:
TfBits supports only the most basic thread safety guarantee: multiple threads may safely call const methods concurrently. A thread must not invoke any non-const method on a TfBits object while any other thread is accessing it.
There are certain members in this class that are mutable and modified in const methods. However, since they are updated without being read and all threads would update them with the same values in the case of a race condition, the worst thing that can happen is redundant computation.
Successive access to these members will result in read only access patterns.
All occurances are marked.
using TfBits::AllSetView = View<AllSet> |
using TfBits::AllUnsetView = View<AllUnset> |
using TfBits::AllView = View<All> |
enum TfBits::Mode |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Flips all bits.
The resulting bit set is the complement of this bit set.
|
inline |
Returns true if this bit array contains rhs
by computing: (rhs - this).GetNumSet() == 0.
Ie. it will return true if all bits of rhs
are also set in this.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
TF_API std::string TfBits::GetAsStringLeftToRight | ( | ) | const |
Returns a string representing the bits for debugging with bits ordered from left to right with increasing indices.
TF_API std::string TfBits::GetAsStringRightToLeft | ( | ) | const |
Returns a string representing the bits for debugging with bits ordered from right to left with increasing indices.
|
inline |
TF_API size_t TfBits::GetHash | ( | ) | const |
Returns a hash for this instance.
|
inline |
|
inline |
|
inline |
|
inline |
Returns true if the result of an asymmetric set different is non-zero. This is the equivalent to computing: return (this - rhs).GetNumSet() != 0 but avoids creating temporary copies.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Ands these bits with the rhs
bits.
The resulting bit set is the intersection of the two bit sets.
Removes all bits in the rhs
bits from these bits.
The resulting bit set is the asymmetric set difference of the two bit sets.
|
inline |
Xors these bits with the rhs
bits.
The resulting bit set is the union of the two bit sets minus the intersection of the two bit sets.
Ors these bits with the rhs
bits.
The resulting bit set is the union of the two bit sets.
|
inline |
Resizes the bit array, however, the bits are left uninitialized. So you most likely want to call ClearAll(); or SetAll();.
|
inline |
|
inline |