aboutsummaryrefslogtreecommitdiffstats
path: root/chilbert
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-08-19 18:22:26 +0200
committerDavid Robillard <d@drobilla.net>2018-09-29 14:50:07 +0200
commitac65326242af579d6e1a7bd71730f1c78c8bde9b (patch)
treeae5225c4b9856b3e5d454378d00867d9b0c53d26 /chilbert
parent7567f77828ff9661f85eabe3b4cfb1876b307d42 (diff)
downloadchilbert-ac65326242af579d6e1a7bd71730f1c78c8bde9b.tar.gz
chilbert-ac65326242af579d6e1a7bd71730f1c78c8bde9b.tar.bz2
chilbert-ac65326242af579d6e1a7bd71730f1c78c8bde9b.zip
Reorganize headers to make a clear public/private distinction
Diffstat (limited to 'chilbert')
-rw-r--r--chilbert/BoundedBitVec.hpp25
-rw-r--r--chilbert/DynamicBitVec.hpp16
-rw-r--r--chilbert/SmallBitVec.hpp13
-rw-r--r--chilbert/StaticBitVec.hpp20
-rw-r--r--chilbert/chilbert.hpp (renamed from chilbert/Hilbert.hpp)2
-rw-r--r--chilbert/chilbert.ipp (renamed from chilbert/Hilbert.ipp)4
-rw-r--r--chilbert/detail/BitVecIndex.hpp (renamed from chilbert/BitVecIndex.hpp)2
-rw-r--r--chilbert/detail/BitVecIterator.hpp (renamed from chilbert/BitVecIterator.hpp)4
-rw-r--r--chilbert/detail/BitVecMask.hpp (renamed from chilbert/BitVecMask.hpp)2
-rw-r--r--chilbert/detail/MultiBitVec.hpp (renamed from chilbert/MultiBitVec.hpp)12
-rw-r--r--chilbert/detail/gray_code_rank.hpp (renamed from chilbert/GrayCodeRank.hpp)2
-rw-r--r--chilbert/detail/operations.hpp (renamed from chilbert/Operations.hpp)6
-rw-r--r--chilbert/detail/traits.hpp (renamed from chilbert/Traits.hpp)2
-rw-r--r--chilbert/operators.hpp (renamed from chilbert/Operators.hpp)4
14 files changed, 76 insertions, 38 deletions
diff --git a/chilbert/BoundedBitVec.hpp b/chilbert/BoundedBitVec.hpp
index 79912cc..fa414ca 100644
--- a/chilbert/BoundedBitVec.hpp
+++ b/chilbert/BoundedBitVec.hpp
@@ -19,11 +19,11 @@
#ifndef CHILBERT_BOUNDEDBITVEC_HPP
#define CHILBERT_BOUNDEDBITVEC_HPP
-#include "chilbert/BitVecIndex.hpp"
-#include "chilbert/BitVecIterator.hpp"
-#include "chilbert/BitVecMask.hpp"
-#include "chilbert/MultiBitVec.hpp"
-#include "chilbert/Operations.hpp"
+#include "chilbert/detail/BitVecIndex.hpp"
+#include "chilbert/detail/BitVecIterator.hpp"
+#include "chilbert/detail/BitVecMask.hpp"
+#include "chilbert/detail/MultiBitVec.hpp"
+#include "chilbert/detail/operations.hpp"
#include <algorithm>
#include <array>
@@ -42,12 +42,12 @@ namespace chilbert {
* @tparam MaxN Maximum number of bits.
*/
template <size_t MaxN>
-class BoundedBitVec : public MultiBitVec<BoundedBitVec<MaxN>>
+class BoundedBitVec : public detail::MultiBitVec<BoundedBitVec<MaxN>>
{
public:
- using Rack = typename MultiBitVec<BoundedBitVec<MaxN>>::Rack;
+ using Rack = typename detail::MultiBitVec<BoundedBitVec<MaxN>>::Rack;
- using MultiBitVec<BoundedBitVec<MaxN>>::bits_per_rack;
+ using detail::MultiBitVec<BoundedBitVec<MaxN>>::bits_per_rack;
BoundedBitVec() = default;
@@ -95,6 +95,8 @@ private:
size_t m_size;
};
+namespace detail {
+
template <size_t MaxN>
struct is_bitvec<BoundedBitVec<MaxN>>
{
@@ -105,16 +107,19 @@ template <size_t MaxN>
void
gray_code(BoundedBitVec<MaxN>& value)
{
- gray_code(static_cast<MultiBitVec<BoundedBitVec<MaxN>>&>(value));
+ gray_code(static_cast<detail::MultiBitVec<BoundedBitVec<MaxN>>&>(value));
}
template <size_t MaxN>
void
gray_code_inv(BoundedBitVec<MaxN>& value)
{
- gray_code_inv(static_cast<MultiBitVec<BoundedBitVec<MaxN>>&>(value));
+ gray_code_inv(
+ static_cast<detail::MultiBitVec<BoundedBitVec<MaxN>>&>(value));
}
+} // namespace detail
+
} // namespace chilbert
#endif
diff --git a/chilbert/DynamicBitVec.hpp b/chilbert/DynamicBitVec.hpp
index 7372629..722b689 100644
--- a/chilbert/DynamicBitVec.hpp
+++ b/chilbert/DynamicBitVec.hpp
@@ -19,11 +19,11 @@
#ifndef CHILBERT_DYNAMICBITVEC_HPP
#define CHILBERT_DYNAMICBITVEC_HPP
-#include "chilbert/BitVecIndex.hpp"
-#include "chilbert/BitVecIterator.hpp"
-#include "chilbert/BitVecMask.hpp"
-#include "chilbert/MultiBitVec.hpp"
-#include "chilbert/Operations.hpp"
+#include "chilbert/detail/BitVecIndex.hpp"
+#include "chilbert/detail/BitVecIterator.hpp"
+#include "chilbert/detail/BitVecMask.hpp"
+#include "chilbert/detail/MultiBitVec.hpp"
+#include "chilbert/detail/operations.hpp"
#include <algorithm>
#include <cstddef>
@@ -38,7 +38,7 @@ namespace chilbert {
* This uses dynamic allocation internally and can be constructed with any
* size, assuming sufficient memory is available.
*/
-class DynamicBitVec : public MultiBitVec<DynamicBitVec>
+class DynamicBitVec : public detail::MultiBitVec<DynamicBitVec>
{
public:
struct RacksDeleter
@@ -128,6 +128,8 @@ private:
size_t m_size;
};
+namespace detail {
+
template <>
struct is_bitvec<DynamicBitVec>
{
@@ -148,6 +150,8 @@ gray_code_inv(DynamicBitVec& value)
gray_code_inv(static_cast<MultiBitVec<DynamicBitVec>&>(value));
}
+} // namespace detail
+
} // namespace chilbert
#endif
diff --git a/chilbert/SmallBitVec.hpp b/chilbert/SmallBitVec.hpp
index 308d943..478cbc9 100644
--- a/chilbert/SmallBitVec.hpp
+++ b/chilbert/SmallBitVec.hpp
@@ -19,7 +19,7 @@
#ifndef CHILBERT_SMALLBITVEC_HPP
#define CHILBERT_SMALLBITVEC_HPP
-#include "chilbert/Operations.hpp"
+#include "chilbert/detail/operations.hpp"
#include <cassert>
#include <climits>
@@ -233,11 +233,14 @@ public:
/// Return 1 + the index of the first set bit, or 0 if there are none
size_t find_first() const
{
- return static_cast<size_t>(chilbert::find_first(m_rack));
+ return static_cast<size_t>(detail::find_first(m_rack));
}
/// Return the number of set bits
- size_t count() const { return static_cast<size_t>(pop_count(m_rack)); }
+ size_t count() const
+ {
+ return static_cast<size_t>(detail::pop_count(m_rack));
+ }
/// Flip all bits (one's complement)
SmallBitVec& flip()
@@ -347,6 +350,8 @@ private:
size_t m_size{};
};
+namespace detail {
+
template <>
struct is_bitvec<SmallBitVec>
{
@@ -367,6 +372,8 @@ gray_code_inv(SmallBitVec& value)
gray_code_inv<SmallBitVec::Rack>(value.rack());
}
+} // namespace detail
+
} // namespace chilbert
#endif
diff --git a/chilbert/StaticBitVec.hpp b/chilbert/StaticBitVec.hpp
index 66d136a..9aff3ad 100644
--- a/chilbert/StaticBitVec.hpp
+++ b/chilbert/StaticBitVec.hpp
@@ -19,11 +19,11 @@
#ifndef CHILBERT_STATICBITVEC_HPP
#define CHILBERT_STATICBITVEC_HPP
-#include "chilbert/BitVecIndex.hpp"
-#include "chilbert/BitVecIterator.hpp"
-#include "chilbert/BitVecMask.hpp"
-#include "chilbert/MultiBitVec.hpp"
-#include "chilbert/Operations.hpp"
+#include "chilbert/detail/BitVecIndex.hpp"
+#include "chilbert/detail/BitVecIterator.hpp"
+#include "chilbert/detail/BitVecMask.hpp"
+#include "chilbert/detail/MultiBitVec.hpp"
+#include "chilbert/detail/operations.hpp"
#include <algorithm>
#include <array>
@@ -43,12 +43,12 @@ namespace chilbert {
* @tparam N Number of bits.
*/
template <size_t N>
-class StaticBitVec : public MultiBitVec<StaticBitVec<N>>
+class StaticBitVec : public detail::MultiBitVec<StaticBitVec<N>>
{
public:
- using Rack = typename MultiBitVec<StaticBitVec<N>>::Rack;
+ using Rack = typename detail::MultiBitVec<StaticBitVec<N>>::Rack;
- using MultiBitVec<StaticBitVec<N>>::bits_per_rack;
+ using detail::MultiBitVec<StaticBitVec<N>>::bits_per_rack;
StaticBitVec() = default;
@@ -91,6 +91,8 @@ private:
std::array<Rack, num_racks()> m_racks{};
};
+namespace detail {
+
template <size_t N>
struct is_bitvec<StaticBitVec<N>>
{
@@ -111,6 +113,8 @@ gray_code_inv(StaticBitVec<N>& value)
gray_code_inv(static_cast<MultiBitVec<StaticBitVec<N>>&>(value));
}
+} // namespace detail
+
} // namespace chilbert
#endif
diff --git a/chilbert/Hilbert.hpp b/chilbert/chilbert.hpp
index 8db5b1c..2954cf3 100644
--- a/chilbert/Hilbert.hpp
+++ b/chilbert/chilbert.hpp
@@ -97,6 +97,6 @@ inline void compact_index_to_coords(P* const p,
} // namespace chilbert
-#include "chilbert/Hilbert.ipp"
+#include "chilbert/chilbert.ipp"
#endif
diff --git a/chilbert/Hilbert.ipp b/chilbert/chilbert.ipp
index 837375e..c4e8249 100644
--- a/chilbert/Hilbert.ipp
+++ b/chilbert/chilbert.ipp
@@ -21,10 +21,10 @@
#include "chilbert/BoundedBitVec.hpp"
#include "chilbert/DynamicBitVec.hpp"
-#include "chilbert/GrayCodeRank.hpp"
-#include "chilbert/Hilbert.hpp"
#include "chilbert/SmallBitVec.hpp"
#include "chilbert/StaticBitVec.hpp"
+#include "chilbert/chilbert.hpp"
+#include "chilbert/detail/gray_code_rank.hpp"
#include <cassert>
#include <climits>
diff --git a/chilbert/BitVecIndex.hpp b/chilbert/detail/BitVecIndex.hpp
index 4038105..e7b385e 100644
--- a/chilbert/BitVecIndex.hpp
+++ b/chilbert/detail/BitVecIndex.hpp
@@ -24,6 +24,7 @@
#include <cstddef>
namespace chilbert {
+namespace detail {
/// Index into a multi-rack bit vector
template <class BitVec>
@@ -44,6 +45,7 @@ struct BitVecIndex
size_t bit;
};
+} // namespace detail
} // namespace chilbert
#endif
diff --git a/chilbert/BitVecIterator.hpp b/chilbert/detail/BitVecIterator.hpp
index bbafd42..8902747 100644
--- a/chilbert/BitVecIterator.hpp
+++ b/chilbert/detail/BitVecIterator.hpp
@@ -19,11 +19,12 @@
#ifndef CHILBERT_BITVECITERATOR_HPP
#define CHILBERT_BITVECITERATOR_HPP
-#include "chilbert/BitVecMask.hpp"
+#include "chilbert/detail/BitVecMask.hpp"
#include <cstddef>
namespace chilbert {
+namespace detail {
template <class BitVec>
class BitVecIteratorBase : public BitVecMask<typename BitVec::Rack>
@@ -93,6 +94,7 @@ private:
}
};
+} // namespace detail
} // namespace chilbert
#endif
diff --git a/chilbert/BitVecMask.hpp b/chilbert/detail/BitVecMask.hpp
index af98894..03eaf5f 100644
--- a/chilbert/BitVecMask.hpp
+++ b/chilbert/detail/BitVecMask.hpp
@@ -23,6 +23,7 @@
#include <cstddef>
namespace chilbert {
+namespace detail {
/** Mask for a bit that can be incremented like an index.
*
@@ -67,6 +68,7 @@ struct BitVecMask
Rack mask;
};
+} // namespace detail
} // namespace chilbert
#endif
diff --git a/chilbert/MultiBitVec.hpp b/chilbert/detail/MultiBitVec.hpp
index 1401fd7..4bf5085 100644
--- a/chilbert/MultiBitVec.hpp
+++ b/chilbert/detail/MultiBitVec.hpp
@@ -19,8 +19,10 @@
#ifndef CHILBERT_MULTIBITVEC_HPP
#define CHILBERT_MULTIBITVEC_HPP
-#include "chilbert/BitVecIterator.hpp"
-#include "chilbert/Operations.hpp"
+#include "chilbert/detail/BitVecIndex.hpp"
+#include "chilbert/detail/BitVecIterator.hpp"
+#include "chilbert/detail/BitVecMask.hpp"
+#include "chilbert/detail/operations.hpp"
#include <cassert>
#include <climits>
@@ -28,6 +30,7 @@
#include <cstring>
namespace chilbert {
+namespace detail {
template <class Derived>
class MultiBitVec
@@ -175,7 +178,7 @@ public:
size_t find_first() const
{
for (size_t i = 0; i < num_racks(); ++i) {
- const int j = chilbert::find_first(rack(i));
+ const int j = chilbert::detail::find_first(rack(i));
if (j) {
return (i * bits_per_rack) + static_cast<size_t>(j);
}
@@ -336,7 +339,7 @@ public:
size_t data_size() const { return self()->data_size(); }
private:
- using Index = BitVecIndex<Derived>;
+ using Index = detail::BitVecIndex<Derived>;
Derived* self() { return static_cast<Derived*>(this); }
const Derived* self() const { return static_cast<const Derived*>(this); }
@@ -374,6 +377,7 @@ gray_code_inv(MultiBitVec<Derived>& value)
}
}
+} // namespace detail
} // namespace chilbert
#endif
diff --git a/chilbert/GrayCodeRank.hpp b/chilbert/detail/gray_code_rank.hpp
index d7fbc77..815519e 100644
--- a/chilbert/GrayCodeRank.hpp
+++ b/chilbert/detail/gray_code_rank.hpp
@@ -24,6 +24,7 @@
#include <numeric>
namespace chilbert {
+namespace detail {
// This is the bulk of the cost in calculating
// a Compact Hilbert Index. It compresses a previously
@@ -175,6 +176,7 @@ extract_mask(const size_t* const ms,
} while (j != d);
}
+} // namespace detail
} // namespace chilbert
#endif
diff --git a/chilbert/Operations.hpp b/chilbert/detail/operations.hpp
index 24474cc..94635b4 100644
--- a/chilbert/Operations.hpp
+++ b/chilbert/detail/operations.hpp
@@ -19,8 +19,8 @@
#ifndef CHILBERT_OPERATIONS_HPP
#define CHILBERT_OPERATIONS_HPP
-#include "chilbert/Operators.hpp"
-#include "chilbert/Traits.hpp"
+#include "chilbert/detail/traits.hpp"
+#include "chilbert/operators.hpp"
#include <cassert>
#include <climits>
@@ -29,6 +29,7 @@
#include <type_traits>
namespace chilbert {
+namespace detail {
/// Reset all bits in `field`
template <typename T>
@@ -161,6 +162,7 @@ gray_code_inv(T& value)
}
}
+} // namespace detail
} // namespace chilbert
#endif
diff --git a/chilbert/Traits.hpp b/chilbert/detail/traits.hpp
index 0c7807d..0cb0f03 100644
--- a/chilbert/Traits.hpp
+++ b/chilbert/detail/traits.hpp
@@ -20,6 +20,7 @@
#define CHILBERT_TRAITS_HPP
namespace chilbert {
+namespace detail {
/// Member `value` is true iff T is a chilbert bitset
template <class T>
@@ -32,6 +33,7 @@ struct is_bitvec
template <class T>
static constexpr bool is_bitvec_v = is_bitvec<T>::value;
+} // namespace detail
} // namespace chilbert
#endif
diff --git a/chilbert/Operators.hpp b/chilbert/operators.hpp
index 683c792..efad7f4 100644
--- a/chilbert/Operators.hpp
+++ b/chilbert/operators.hpp
@@ -19,13 +19,15 @@
#ifndef CHILBERT_OPERATORS_HPP
#define CHILBERT_OPERATORS_HPP
-#include "chilbert/Traits.hpp"
+#include "chilbert/detail/traits.hpp"
#include <iostream>
#include <type_traits>
namespace chilbert {
+using detail::is_bitvec_v;
+
template <class T>
std::enable_if_t<is_bitvec_v<T>, T> operator&(const T& lhs, const T& rhs)
{