Template Class ListSet

Class Documentation

template<std::equality_comparable T>
class ListSet

a set as an unsorted list

Public Types

using Item = T

the type of the items

using value_type = T
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = const T&
using const_reference = const T&
using const_iterator = typename List<T>::const_iterator
using iterator = const_iterator

Public Functions

ListSet(void) = default
ListSet(std::initializer_list<T> items)
std::size_t size(void) const
bool empty(void) const
bool contains(const T &x) const
void insert(const T &x)

O( n ) time, for the check that x is not there.

Post:

x is in the set

void insertNew(const T &x)

inserts x, which must not be there, at the head, O( 1 ) time

Pre:

x is not in the set (an audit, O( n ))

void remove(const T &x)
Post:

x is not in the set

std::optional<T> min(void) const

the smallest item, O( n ) time

template<class F>
void forEach(F &&f) const

f( x ) on the items, from the last inserted, O( n ) time

inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const