From c48d56bcc0c919007d712d8716c86714e387554b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 19 Aug 2018 17:51:42 +0200 Subject: Document various bit vector types --- chilbert/BoundedBitVec.hpp | 7 +++++++ chilbert/DynamicBitVec.hpp | 5 +++++ chilbert/SmallBitVec.hpp | 1 + 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 class BoundedBitVec : public MultiBitVec> { 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 { 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 class StaticBitVec : public MultiBitVec> { @@ -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) -- cgit v1.2.1