Template Class SortedListSet

Class Documentation

template<std::totally_ordered T>
class SortedListSet

a set as a list sorted in increasing order

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

SortedListSet(void) = default
SortedListSet(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, to keep the order.

Post:

x is in the set

void insertLast(const T &x)

appends x, larger than all the items, O( 1 ) time

Pre:

the set is empty or its largest item is smaller than x

void remove(const T &x)
Post:

x is not in the set

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

the smallest item, O( 1 ) time

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

the largest item, O( 1 ) time

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

f( x ) on the items in increasing order, O( n ) time

const List<T> &list(void) const

the sorted list of the items

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