Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::BitSet< N > Class Template Reference

#include <bit_set.h>

Public Member Functions

 BitSet ()
 
void Set (intptr_t i, bool value)
 
bool Test (intptr_t i) const
 
intptr_t Next (intptr_t i) const
 
intptr_t Last () const
 
intptr_t ClearLastAndFindPrevious (intptr_t current_last)
 
void Reset ()
 
intptr_t Size () const
 

Detailed Description

template<intptr_t N>
class dart::BitSet< N >

Definition at line 16 of file bit_set.h.

Constructor & Destructor Documentation

◆ BitSet()

template<intptr_t N>
dart::BitSet< N >::BitSet ( )
inline

Definition at line 18 of file bit_set.h.

18{ Reset(); }
void Reset()
Definition: bit_set.h:89

Member Function Documentation

◆ ClearLastAndFindPrevious()

template<intptr_t N>
intptr_t dart::BitSet< N >::ClearLastAndFindPrevious ( intptr_t  current_last)
inline

Definition at line 67 of file bit_set.h.

67 {
68 ASSERT(Test(current_last));
69 ASSERT(Last() == current_last);
70 intptr_t w = current_last >> kBitsPerWordLog2;
71 uword bits = data_[w];
72 // Clear the current last.
73 bits ^= (static_cast<uword>(1) << (current_last & (kBitsPerWord - 1)));
74 data_[w] = bits;
75 // Search backwards for a non-zero word.
76 while (bits == 0 && w > 0) {
77 bits = data_[--w];
78 }
79 if (bits == 0) {
80 // None found.
81 return -1;
82 } else {
83 // Bitlength incl. w, minus leading zeroes of w, minus 1 to 0-based index.
84 return ((w + 1) << kBitsPerWordLog2) -
86 }
87 }
intptr_t Last() const
Definition: bit_set.h:56
bool Test(intptr_t i) const
Definition: bit_set.h:31
static int CountLeadingZerosWord(uword x)
Definition: utils.h:247
#define ASSERT(E)
constexpr intptr_t kBitsPerWordLog2
Definition: globals.h:513
constexpr intptr_t kBitsPerWord
Definition: globals.h:514
uintptr_t uword
Definition: globals.h:501
SkScalar w

◆ Last()

template<intptr_t N>
intptr_t dart::BitSet< N >::Last ( ) const
inline

Definition at line 56 of file bit_set.h.

56 {
57 for (int w = kLengthInWords - 1; w >= 0; --w) {
58 uword d = data_[w];
59 if (d != 0) {
61 1;
62 }
63 }
64 return -1;
65 }
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19

◆ Next()

template<intptr_t N>
intptr_t dart::BitSet< N >::Next ( intptr_t  i) const
inline

Definition at line 38 of file bit_set.h.

38 {
39 ASSERT(i >= 0);
40 ASSERT(i < N);
41 intptr_t w = i >> kBitsPerWordLog2;
42 uword mask = ~static_cast<uword>(0) << (i & (kBitsPerWord - 1));
43 if ((data_[w] & mask) != 0) {
44 uword tz = Utils::CountTrailingZerosWord(data_[w] & mask);
45 return (w << kBitsPerWordLog2) + tz;
46 }
47 while (++w < kLengthInWords) {
48 if (data_[w] != 0) {
49 return (w << kBitsPerWordLog2) +
51 }
52 }
53 return -1;
54 }
#define N
Definition: beziers.cpp:19
static int CountTrailingZerosWord(uword x)
Definition: utils.h:281

◆ Reset()

template<intptr_t N>
void dart::BitSet< N >::Reset ( )
inline

Definition at line 89 of file bit_set.h.

89{ memset(data_, 0, sizeof(data_)); }

◆ Set()

template<intptr_t N>
void dart::BitSet< N >::Set ( intptr_t  i,
bool  value 
)
inline

Definition at line 20 of file bit_set.h.

20 {
21 ASSERT(i >= 0);
22 ASSERT(i < N);
23 uword mask = (static_cast<uword>(1) << (i & (kBitsPerWord - 1)));
24 if (value) {
25 data_[i >> kBitsPerWordLog2] |= mask;
26 } else {
27 data_[i >> kBitsPerWordLog2] &= ~mask;
28 }
29 }
uint8_t value

◆ Size()

template<intptr_t N>
intptr_t dart::BitSet< N >::Size ( ) const
inline

Definition at line 91 of file bit_set.h.

91{ return N; }

◆ Test()

template<intptr_t N>
bool dart::BitSet< N >::Test ( intptr_t  i) const
inline

Definition at line 31 of file bit_set.h.

31 {
32 ASSERT(i >= 0);
33 ASSERT(i < N);
34 uword mask = (static_cast<uword>(1) << (i & (kBitsPerWord - 1)));
35 return (data_[i >> kBitsPerWordLog2] & mask) != 0;
36 }

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