Home | History | Annotate | Download | only in base

Lines Matching defs:BitString

32  * into a BitString, while restricting the bitlength.
37 * See also BitString below.
55 // (Data could use less bits, but this is the maximum bit capacity at that BitString position).
95 // (Useful to figure out the maximum value for this BitString position.)
115 * BitString
126 * bitlength, as defined by len[pos]. This BitString can be nested inside of a BitStruct
132 * // Padded with trailing 0s to fit (N+1) bitstring chars.
134 * StrLen(Bitstring) := I s.t. (I == 0 OR Char(I-1) != 0)
137 * Bitstring[N] := CharN
138 * Bitstring[I..N) := [CharI, CharI+1, ... CharN-1]
142 struct BitString {
151 // How many bits are needed to represent BitString[0..position)?
181 // See also "BitString[N]" in the doc header.
204 // How many characters are there in this bitstring?
206 // See also "StrLen(BitString)" in the doc header.
235 BitString() = default;
237 // Efficient O(1) comparison: Equal if both bitstring words are the same.
238 bool operator==(const BitString& other) const {
242 // Efficient O(1) negative comparison: Not-equal if both bitstring words are different.
243 bool operator!=(const BitString& other) const {
247 // Does this bitstring contain exactly 0 characters?
249 return (*this) == BitString{};
253 // Returns the BitString[0..end) substring as a copy.
254 // See also "BitString[I..N)" in the doc header.
255 BitString Truncate(size_t end) {
257 BitString copy = *this;
270 friend std::ostream& operator<<(std::ostream& os, const BitString& bit_string);
277 static_assert(BitSizeOf<BitString::StorageType>() >=
278 BitString::GetBitLengthTotalAtPosition(BitString::kCapacity),
281 // Print e.g. "BitString[1,0,3]". Trailing 0s are dropped.
282 inline std::ostream& operator<<(std::ostream& os, const BitString& bit_string) {
285 os << "BitString[";
291 os << static_cast<BitString::StorageType>(bc);