VapourSynth-llvmexpr
Loading...
Searching...
No Matches
analysis::dynamic_bitset::DynamicBitset Class Reference

#include <llvmexpr/analysis/utils/DynamicBitset.hpp>

Public Member Functions

 DynamicBitset (int n=0)
void setAll () noexcept
void resetAll () noexcept
void set (int i) noexcept
void reset (int i) noexcept
bool test (int i) const noexcept
bool intersectWith (const DynamicBitset &other) noexcept
bool equals (const DynamicBitset &other) const noexcept

Detailed Description

Definition at line 29 of file DynamicBitset.hpp.

Constructor & Destructor Documentation

◆ DynamicBitset()

analysis::dynamic_bitset::DynamicBitset::DynamicBitset ( int n = 0)
inlineexplicit

Definition at line 50 of file DynamicBitset.hpp.

51 : words((static_cast<size_t>(n) + (BITS_PER_WORD - 1)) / BITS_PER_WORD,
52 0),
53 nbits(n) {}

Referenced by equals(), and intersectWith().

Member Function Documentation

◆ equals()

bool analysis::dynamic_bitset::DynamicBitset::equals ( const DynamicBitset & other) const
inlinenodiscardnoexcept

Definition at line 105 of file DynamicBitset.hpp.

105 {
106 return nbits == other.nbits && words == other.words;
107 }

References DynamicBitset().

◆ intersectWith()

bool analysis::dynamic_bitset::DynamicBitset::intersectWith ( const DynamicBitset & other)
inlinenoexcept

Definition at line 78 of file DynamicBitset.hpp.

78 {
79 bool changed = false;
80
81 if (other.words.size() == words.size()) {
82 for (size_t i = 0; i < words.size(); ++i) {
83 const std::uint64_t nw = words[i] & other.words[i];
84 changed |= (nw != words[i]);
85 words[i] = nw;
86 }
87 maskUnusedBits();
88 return changed;
89 }
90
91 const size_t n = std::min(words.size(), other.words.size());
92 for (size_t i = 0; i < n; ++i) {
93 const std::uint64_t nw = words[i] & other.words[i];
94 changed |= (nw != words[i]);
95 words[i] = nw;
96 }
97 for (size_t i = n; i < words.size(); ++i) {
98 changed |= (words[i] != 0);
99 words[i] = 0;
100 }
101 maskUnusedBits();
102 return changed;
103 }

References DynamicBitset().

◆ reset()

void analysis::dynamic_bitset::DynamicBitset::reset ( int i)
inlinenoexcept

Definition at line 67 of file DynamicBitset.hpp.

67 {
68 words[static_cast<size_t>(i) / BITS_PER_WORD] &=
69 ~(std::uint64_t(1) << static_cast<unsigned>(i % BITS_PER_WORD));
70 }

◆ resetAll()

void analysis::dynamic_bitset::DynamicBitset::resetAll ( )
inlinenoexcept

Definition at line 60 of file DynamicBitset.hpp.

60{ std::ranges::fill(words, 0); }

◆ set()

void analysis::dynamic_bitset::DynamicBitset::set ( int i)
inlinenoexcept

Definition at line 62 of file DynamicBitset.hpp.

62 {
63 words[static_cast<size_t>(i) / BITS_PER_WORD] |=
64 (std::uint64_t(1) << static_cast<unsigned>(i % BITS_PER_WORD));
65 }

◆ setAll()

void analysis::dynamic_bitset::DynamicBitset::setAll ( )
inlinenoexcept

Definition at line 55 of file DynamicBitset.hpp.

55 {
56 std::ranges::fill(words, ~std::uint64_t(0));
57 maskUnusedBits();
58 }

◆ test()

bool analysis::dynamic_bitset::DynamicBitset::test ( int i) const
inlinenodiscardnoexcept

Definition at line 72 of file DynamicBitset.hpp.

72 {
73 return (((words[static_cast<size_t>(i) / BITS_PER_WORD] >>
74 static_cast<unsigned>(i % BITS_PER_WORD)) &
75 1U) != 0);
76 }

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