An adapter class for std::vector that acts like an ordered set and stores its data in the underlying vector in order.
More...
|
|
| TinySet () |
| Default constructor.
|
|
| TinySet (std::initializer_list< T > list) |
| Initializer-list constructor.
|
|
|
void | clear () |
| Empties the set.
|
|
template<typename It > |
void | erase (It a) |
| Erases an element marked by a position in the set.
|
|
void | reserve (std::size_t size) |
| Reserves space in memory.
|
|
iterator | find (const T &a) |
| Finds an element in the set.
|
|
void | insert (T a) |
| Inserts an element into the set. More...
|
|
template<typename It > |
void | insert (It a, const It &b) |
| Inserts all elements contained in a range. More...
|
|
void | emplace (T a) |
| Insert an element. More...
|
|
TinySet & | operator= (std::initializer_list< T > init) |
| Assign from an initializer list. More...
|
|
|
unsigned | count (T a) const |
| Count the number of occurrences of an element.
|
|
bool | empty () const |
| Returns whether the set is empty.
|
|
std::size_t | size () const |
| Returns the number of contained elements.
|
|
|
const_reference | front () const |
| Yields a const reference to the first element in the set.
|
|
const_reference | back () const |
| Yields a const reference to the last element in the set.
|
|
const_reference | at (std::size_t position) const |
| Yields a const reference to an element in the set.
|
|
|
iterator | begin () |
| Yields a begin iterator.
|
|
iterator | end () |
| Yields an end iterator.
|
|
const_iterator | begin () const |
| Yields a begin const iterator.
|
|
const_iterator | end () const |
| Yields an end const iterator.
|
|
const_iterator | cbegin () const |
| Yields a begin const iterator.
|
|
const_iterator | cend () const |
| Yields an end const iterator.
|
|
|
bool | operator== (const TinySet &other) const |
| Lexicographically compare two sets.
|
|
bool | operator!= (const TinySet &other) const |
| Invertes operator== .
|
|
|
|
static iterator | find (std::vector< T > &set, const T &a) |
| Emplaces an element in an ordered vector if the element is not contained. More...
|
|
static const_iterator | find (const std::vector< T > &set, const T &a) |
| Emplaces an element in an ordered vector if the element is not contained. More...
|
|
static void | checked_insert (std::vector< T > &set, T a) |
| Emplaces an element in an ordered vector if the element is not contained. More...
|
|
template<typename... Args> |
static void | checked_emplace (std::vector< T > &set, Args &&...args) |
| Emplaces an element in an ordered vector if the element is not contained. More...
|
|
static bool | binary_search (const std::vector< T > &set, const T &value) |
| Binary search for a value in an ordered set. More...
|
|
template<typename T>
struct Scine::Molassembler::Temple::TinySet< T >
An adapter class for std::vector that acts like an ordered set and stores its data in the underlying vector in order.
Why? It's a lot simpler / smaller than set and seems to be faster for very small amounts of data. Break-even with an unordered_set for finding a value is at around N = 200 for numeric types, although I certainly do not trust the benchmark much.
- Template Parameters
-