13 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_CONSTEXPR_DYNAMIC_SET_H
14 #define INCLUDE_MOLASSEMBLER_TEMPLE_CONSTEXPR_DYNAMIC_SET_H
19 namespace Molassembler {
32 class LessThanPredicate = std::less<T>,
33 class EqualityPredicate = std::equal_to<T>
49 template<
typename,
size_t>
class ArrayType,
51 > constexpr
DynamicSet(
const ArrayType<T, size>& items) {
52 for(
const auto& item : items) {
69 constexpr
void insert(
const T& item) {
82 using const_iterator =
typename TreeType::const_iterator;
84 PURITY_WEAK constexpr const_iterator begin()
const {
97 return tree_ == other.tree_;
107 return tree_ < other.tree_;
111 return other.tree_ < tree_;
119 template<
typename,
size_t>
class ArrayType,
120 class LessThanPredicate = std::less<T>,
121 class EqualityPredicate = std::equal_to<T>
123 const ArrayType<T, nItems>& array
PURITY_WEAK constexpr bool contains(const T &item) const
Check if the set contains an element.
Definition: DynamicSet.h:61
#define PURITY_WEAK
Definition: Preprocessor.h:36
An Option monadic type.
Definition: Optional.h:33
constexpr DynamicSet(const ArrayType< T, size > &items)
Constructor from existing ordered data.
Definition: DynamicSet.h:51
PURITY_WEAK constexpr const_iterator end() const
Returns a past-the-end const iterator.
Definition: BTree.h:615
PURITY_WEAK constexpr Optional< const T & > getOption(const T &value) const
Checks if the tree contains T. If so, returns a const-ref to it.
Definition: BTree.h:245
PURITY_WEAK constexpr unsigned size() const
Returns the number of elements in the tree.
Definition: BTree.h:340
constexpr DynamicSet< T, nItems, LessThanPredicate > makeDynamicSet(const ArrayType< T, nItems > &array)
Helper function to create a DynamicSet specifying only the maximum size.
Definition: DynamicSet.h:122
constexpr void insert(const T &value)
Add a value to the tree.
Definition: BTree.h:181
constexpr DynamicSet()=default
Dynamic set.
PURITY_WEAK constexpr const_iterator begin() const
Returns a const iterator to the first value in the tree.
Definition: BTree.h:607
constexpr void clear()
Remove all elements of the set.
Definition: DynamicSet.h:78
Tree-based set.
Definition: DynamicSet.h:34
constexpr void clear()
Clears the tree.
Definition: BTree.h:160
PURITY_WEAK constexpr bool contains(const T &value) const
Check whether a value exists in the tree.
Definition: BTree.h:231
constexpr void insert(const T &item)
Insertion an element into the set.
Definition: DynamicSet.h:69