MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / set

Method set

src/common/classes/sparse_bitmap.h:87–126  ·  view source on GitHub ↗

Set bit

Source from the content-addressed store, hash-verified

85
86 // Set bit
87 void set(T value)
88 {
89 if (singular)
90 {
91 // If we are trying to set the same bit as already set - do nothing
92 if (singular_value == value)
93 return;
94
95 // Add singular value to the tree
96 fb_assert(tree.isEmpty());
97
98 singular = false;
99
100 Bucket bucket;
101 bucket.start_value = singular_value & ~(T) (BUNCH_BITS - 1);
102 bucket.bits = BUNCH_ONE << (singular_value - bucket.start_value);
103 tree.add(bucket);
104 }
105 else
106 {
107 if (tree.isEmpty())
108 {
109 singular = true;
110 singular_value = value;
111 return;
112 }
113 }
114
115 const T val_aligned = value & ~(T) (BUNCH_BITS - 1);
116 const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
117
118 Bucket bucket;
119 bucket.start_value = val_aligned;
120 bucket.bits = bit_mask;
121 if (tree.isPositioned(val_aligned) || !tree.add(bucket))
122 {
123 fb_assert(tree.isPositioned(val_aligned));
124 tree.current().bits |= bit_mask;
125 }
126 }
127
128 bool clear(T value)
129 {

Callers 1

bit_orMethod · 0.45

Calls 4

isEmptyMethod · 0.45
addMethod · 0.45
isPositionedMethod · 0.45
currentMethod · 0.45

Tested by

no test coverage detected