Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
DenseStaticIntSet< Index, maxIndexPlusOne > Struct Template Reference

#include <DenseStaticIntSet.h>

Public Member Functions

 DenseStaticIntSet ()
 
 DenseStaticIntSet (Index index)
 
bool contains (Index index) const
 
bool isEmpty () const
 
Index getSmallestMember () const
 
void add (Index index)
 
void addRange (Index rangeMin, Index rangeMax)
 
bool remove (Index index)
 

Friends

DenseStaticIntSet operator~ (const DenseStaticIntSet &set)
 
DenseStaticIntSet operator| (const DenseStaticIntSet &left, const DenseStaticIntSet &right)
 
DenseStaticIntSet operator& (const DenseStaticIntSet &left, const DenseStaticIntSet &right)
 
DenseStaticIntSet operator^ (const DenseStaticIntSet &left, const DenseStaticIntSet &right)
 
bool operator== (const DenseStaticIntSet &left, const DenseStaticIntSet &right)
 
bool operator!= (const DenseStaticIntSet &left, const DenseStaticIntSet &right)
 
bool operator< (const DenseStaticIntSet &left, const DenseStaticIntSet &right)
 

Detailed Description

template<typename Index, Uptr maxIndexPlusOne>
struct DenseStaticIntSet< Index, maxIndexPlusOne >

Definition at line 14 of file DenseStaticIntSet.h.

Constructor & Destructor Documentation

◆ DenseStaticIntSet() [1/2]

template<typename Index , Uptr maxIndexPlusOne>
DenseStaticIntSet< Index, maxIndexPlusOne >::DenseStaticIntSet ( )
inline

Definition at line 16 of file DenseStaticIntSet.h.

17 {
18 memset(elements,0,sizeof(elements));
19 }
memset(pInfo->slotDescription, ' ', 64)
Here is the call graph for this function:

◆ DenseStaticIntSet() [2/2]

template<typename Index , Uptr maxIndexPlusOne>
DenseStaticIntSet< Index, maxIndexPlusOne >::DenseStaticIntSet ( Index index)
inline

Definition at line 20 of file DenseStaticIntSet.h.

21 {
22 memset(elements,0,sizeof(elements));
23 add(index);
24 }
void add(Index index)
Here is the call graph for this function:

Member Function Documentation

◆ add()

template<typename Index , Uptr maxIndexPlusOne>
void DenseStaticIntSet< Index, maxIndexPlusOne >::add ( Index index)
inline

Definition at line 60 of file DenseStaticIntSet.h.

61 {
62 WAVM_ASSERT_THROW((Uptr)index < maxIndexPlusOne);
63 elements[index / indicesPerElement] |= Element(1) << (index % indicesPerElement);
64 }
PointerIntHelper< sizeof(size_t)>::UnsignedIntType Uptr
Definition BasicTypes.h:22
#define WAVM_ASSERT_THROW(cond)
Definition Errors.h:29
Here is the caller graph for this function:

◆ addRange()

template<typename Index , Uptr maxIndexPlusOne>
void DenseStaticIntSet< Index, maxIndexPlusOne >::addRange ( Index rangeMin,
Index rangeMax )
inline

Definition at line 65 of file DenseStaticIntSet.h.

66 {
67 WAVM_ASSERT_THROW(rangeMin <= rangeMax);
68 WAVM_ASSERT_THROW((Uptr)rangeMax < maxIndexPlusOne);
69 for(Index index = rangeMin;index <= rangeMax;++index)
70 {
71 add(index);
72 }
73 }
Here is the call graph for this function:

◆ contains()

template<typename Index , Uptr maxIndexPlusOne>
bool DenseStaticIntSet< Index, maxIndexPlusOne >::contains ( Index index) const
inline

Definition at line 28 of file DenseStaticIntSet.h.

29 {
30 WAVM_ASSERT_THROW((Uptr)index < maxIndexPlusOne);
31 return (elements[index / indicesPerElement] & (Element(1) << (index % indicesPerElement))) != 0;
32 }
Here is the caller graph for this function:

◆ getSmallestMember()

template<typename Index , Uptr maxIndexPlusOne>
Index DenseStaticIntSet< Index, maxIndexPlusOne >::getSmallestMember ( ) const
inline

Definition at line 42 of file DenseStaticIntSet.h.

43 {
44 // Find the first element that has any bits set.
45 for(Uptr elementIndex = 0;elementIndex < numElements;++elementIndex)
46 {
47 if(elements[elementIndex])
48 {
49 // Find the index of the lowest set bit in the element using countTrailingZeroes.
50 const Index result = (Index)(elementIndex * indicesPerElement + Platform::countTrailingZeroes(elements[elementIndex]));
52 return result;
53 }
54 }
55 return maxIndexPlusOne;
56 }
U64 countTrailingZeroes(U64 value)
Definition Platform.h:27
bool contains(Index index) const
Here is the call graph for this function:

◆ isEmpty()

template<typename Index , Uptr maxIndexPlusOne>
bool DenseStaticIntSet< Index, maxIndexPlusOne >::isEmpty ( ) const
inline

Definition at line 33 of file DenseStaticIntSet.h.

34 {
35 Element combinedElements = 0;
36 for(Uptr elementIndex = 0;elementIndex < numElements;++elementIndex)
37 {
38 combinedElements |= elements[elementIndex];
39 }
40 return combinedElements == 0;
41 }

◆ remove()

template<typename Index , Uptr maxIndexPlusOne>
bool DenseStaticIntSet< Index, maxIndexPlusOne >::remove ( Index index)
inline

Definition at line 74 of file DenseStaticIntSet.h.

75 {
76 const Element elementMask = Element(1) << (index % indicesPerElement);
77 const bool hadIndex = (elements[index / indicesPerElement] & elementMask) != 0;
78 elements[index / indicesPerElement] &= ~elementMask;
79 return hadIndex;
80 }

Friends And Related Symbol Documentation

◆ operator!=

template<typename Index , Uptr maxIndexPlusOne>
bool operator!= ( const DenseStaticIntSet< Index, maxIndexPlusOne > & left,
const DenseStaticIntSet< Index, maxIndexPlusOne > & right )
friend

Definition at line 127 of file DenseStaticIntSet.h.

128 {
129 return memcmp(left.elements,right.elements,sizeof(DenseStaticIntSet::elements)) != 0;
130 }

◆ operator&

template<typename Index , Uptr maxIndexPlusOne>
DenseStaticIntSet operator& ( const DenseStaticIntSet< Index, maxIndexPlusOne > & left,
const DenseStaticIntSet< Index, maxIndexPlusOne > & right )
friend

Definition at line 102 of file DenseStaticIntSet.h.

103 {
104 DenseStaticIntSet result;
105 for(Uptr elementIndex = 0;elementIndex < numElements;++elementIndex)
106 {
107 result.elements[elementIndex] = left.elements[elementIndex] & right.elements[elementIndex];
108 }
109 return result;
110 }

◆ operator<

template<typename Index , Uptr maxIndexPlusOne>
bool operator< ( const DenseStaticIntSet< Index, maxIndexPlusOne > & left,
const DenseStaticIntSet< Index, maxIndexPlusOne > & right )
friend

Definition at line 131 of file DenseStaticIntSet.h.

132 {
133 return memcmp(left.elements,right.elements,sizeof(DenseStaticIntSet::elements)) < 0;
134 }

◆ operator==

template<typename Index , Uptr maxIndexPlusOne>
bool operator== ( const DenseStaticIntSet< Index, maxIndexPlusOne > & left,
const DenseStaticIntSet< Index, maxIndexPlusOne > & right )
friend

Definition at line 123 of file DenseStaticIntSet.h.

124 {
125 return memcmp(left.elements,right.elements,sizeof(DenseStaticIntSet::elements)) == 0;
126 }

◆ operator^

template<typename Index , Uptr maxIndexPlusOne>
DenseStaticIntSet operator^ ( const DenseStaticIntSet< Index, maxIndexPlusOne > & left,
const DenseStaticIntSet< Index, maxIndexPlusOne > & right )
friend

Definition at line 111 of file DenseStaticIntSet.h.

112 {
113 DenseStaticIntSet result;
114 for(Uptr elementIndex = 0;elementIndex < numElements;++elementIndex)
115 {
116 result.elements[elementIndex] = left.elements[elementIndex] ^ right.elements[elementIndex];
117 }
118 return result;
119 }

◆ operator|

template<typename Index , Uptr maxIndexPlusOne>
DenseStaticIntSet operator| ( const DenseStaticIntSet< Index, maxIndexPlusOne > & left,
const DenseStaticIntSet< Index, maxIndexPlusOne > & right )
friend

Definition at line 93 of file DenseStaticIntSet.h.

94 {
95 DenseStaticIntSet result;
96 for(Uptr elementIndex = 0;elementIndex < numElements;++elementIndex)
97 {
98 result.elements[elementIndex] = left.elements[elementIndex] | right.elements[elementIndex];
99 }
100 return result;
101 }

◆ operator~

template<typename Index , Uptr maxIndexPlusOne>
DenseStaticIntSet operator~ ( const DenseStaticIntSet< Index, maxIndexPlusOne > & set)
friend

Definition at line 84 of file DenseStaticIntSet.h.

85 {
86 DenseStaticIntSet result;
87 for(Uptr elementIndex = 0;elementIndex < numElements;++elementIndex)
88 {
89 result.elements[elementIndex] = ~set.elements[elementIndex];
90 }
91 return result;
92 }

The documentation for this struct was generated from the following file: