diff options
author | David Robillard <d@drobilla.net> | 2018-08-19 17:51:42 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-29 14:49:45 +0200 |
commit | c48d56bcc0c919007d712d8716c86714e387554b (patch) | |
tree | 60741b1bbf9da108303068d6e503c9e8cfce9a8b | |
parent | 864a0cab22998cfd465f3dd2f0514f96c907ed95 (diff) | |
download | chilbert-c48d56bcc0c919007d712d8716c86714e387554b.tar.gz chilbert-c48d56bcc0c919007d712d8716c86714e387554b.tar.bz2 chilbert-c48d56bcc0c919007d712d8716c86714e387554b.zip |
Document various bit vector types
-rw-r--r-- | chilbert/BoundedBitVec.hpp | 7 | ||||
-rw-r--r-- | chilbert/DynamicBitVec.hpp | 5 | ||||
-rw-r--r-- | chilbert/SmallBitVec.hpp | 1 | ||||
-rw-r--r-- | chilbert/StaticBitVec.hpp | 12 |
4 files changed, 21 insertions, 4 deletions
diff --git a/chilbert/BoundedBitVec.hpp b/chilbert/BoundedBitVec.hpp index 30ab21e..79912cc 100644 --- a/chilbert/BoundedBitVec.hpp +++ b/chilbert/BoundedBitVec.hpp @@ -34,6 +34,13 @@ namespace chilbert { +/** A statically allocated bit vector with a dynamic size. + * + * This can be used to have bit vectors of an arbitrary dynamic size, under + * some static bound, without using dynamic allocation. + * + * @tparam MaxN Maximum number of bits. + */ template <size_t MaxN> class BoundedBitVec : public MultiBitVec<BoundedBitVec<MaxN>> { diff --git a/chilbert/DynamicBitVec.hpp b/chilbert/DynamicBitVec.hpp index ab7d00b..7372629 100644 --- a/chilbert/DynamicBitVec.hpp +++ b/chilbert/DynamicBitVec.hpp @@ -33,6 +33,11 @@ namespace chilbert { +/** A dynamically allocated bit vector. + * + * This uses dynamic allocation internally and can be constructed with any + * size, assuming sufficient memory is available. + */ class DynamicBitVec : public MultiBitVec<DynamicBitVec> { public: diff --git a/chilbert/SmallBitVec.hpp b/chilbert/SmallBitVec.hpp index f11dab0..96652e9 100644 --- a/chilbert/SmallBitVec.hpp +++ b/chilbert/SmallBitVec.hpp @@ -40,6 +40,7 @@ typedef uint64_t FBV_UINT; #define FBV1S (~FBV_UINT{0}) #define FBVN1S(n) (n == FBV_BITS ? FBV1S : (FBV1 << n) - 1) +/** A bit vector small enough to fit in a single word. */ class SmallBitVec { public: diff --git a/chilbert/StaticBitVec.hpp b/chilbert/StaticBitVec.hpp index 24152e1..66d136a 100644 --- a/chilbert/StaticBitVec.hpp +++ b/chilbert/StaticBitVec.hpp @@ -35,6 +35,13 @@ namespace chilbert { +/** A statically sized bit vector. + * + * This has a static number of bits encoded in the type, like std::bitset, and + * does not use dynamic allocation or store a dynamic size. + * + * @tparam N Number of bits. + */ template <size_t N> class StaticBitVec : public MultiBitVec<StaticBitVec<N>> { @@ -46,10 +53,7 @@ public: StaticBitVec() = default; /// Constructor for compatibility with DynamicBitVec - explicit StaticBitVec(const size_t bits) - { - assert(bits == size()); - } + explicit StaticBitVec(const size_t bits) { assert(bits == size()); } /// Constructor for compatibility with DynamicBitVec StaticBitVec(const size_t bits, const Rack value) |