a set as an unsorted list
More...
#include <ADS/set/ListSet.h>
|
| | ListSet (void)=default |
| | the empty set
|
| | ListSet (std::initializer_list< T > items) |
| | the set of the given items, a repeated one taken once
|
| std::size_t | size (void) const |
| | the number of items
|
| bool | empty (void) const |
| | whether the set has no item
|
| bool | contains (const T &x) const |
| | whether \( x \) is in the set, by a scan of the list, \( O( n ) \) time
|
| void | insert (const T &x) |
| | \( x \) into the set, \( O( n ) \) time, for the check that \( x \) is not there
|
| void | insertNew (const T &x) |
| | \( x \), which must not be there, at the head of the list, \( O( 1 ) \) time
|
| void | remove (const T &x) |
| | \( x \) out of the set, \( O( n ) \) time
|
| std::optional< T > | min (void) const |
| | the smallest item, none if the set is empty, by a scan, \( O( n ) \) time
|
| template<class F> |
| void | forEach (F &&f) const |
| | f( x ) on the items, from the last inserted, \( O( n ) \) time
|
| const_iterator | begin (void) const |
| | the iterator on the item at the head of the list
|
| const_iterator | end (void) const |
| | the iterator past the last item
|
| const_iterator | cbegin (void) const |
| | as begin()
|
| const_iterator | cend (void) const |
| | as end()
|
template<std::equality_comparable T>
class ADS::ListSet< T >
a set as an unsorted list
◆ const_iterator
template<std::equality_comparable T>
the iterator of the list, constant
◆ const_reference
template<std::equality_comparable T>
◆ difference_type
template<std::equality_comparable T>
◆ Item
template<std::equality_comparable T>
◆ iterator
template<std::equality_comparable T>
◆ reference
template<std::equality_comparable T>
◆ size_type
template<std::equality_comparable T>
◆ value_type
template<std::equality_comparable T>
◆ ListSet() [1/2]
template<std::equality_comparable T>
◆ ListSet() [2/2]
template<std::equality_comparable T>
| ADS::ListSet< T >::ListSet |
( |
std::initializer_list< T > | items | ) |
|
the set of the given items, a repeated one taken once
◆ begin()
template<std::equality_comparable T>
the iterator on the item at the head of the list
◆ cbegin()
template<std::equality_comparable T>
◆ cend()
template<std::equality_comparable T>
◆ contains()
template<std::equality_comparable T>
whether \( x \) is in the set, by a scan of the list, \( O( n ) \) time
◆ empty()
template<std::equality_comparable T>
whether the set has no item
◆ end()
template<std::equality_comparable T>
the iterator past the last item
◆ forEach()
template<std::equality_comparable T>
template<class F>
f( x ) on the items, from the last inserted, \( O( n ) \) time
◆ insert()
template<std::equality_comparable T>
\( x \) into the set, \( O( n ) \) time, for the check that \( x \) is not there
In pseudocode (section 8.2):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{insert}( x ) \cr
2 & \quad \textbf{if not}\ \mathrm{contains}( x )\ \textbf{then}
\ \mathrm{insertNew}( x )
\end{array}}
\]
- Postcondition
- \( x \) is in the set
◆ insertNew()
template<std::equality_comparable T>
\( x \), which must not be there, at the head of the list, \( O( 1 ) \) time
- Precondition
- \( x \) is not in the set (an audit, \( O( n ) \))
◆ min()
template<std::equality_comparable T>
the smallest item, none if the set is empty, by a scan, \( O( n ) \) time
◆ remove()
template<std::equality_comparable T>
\( x \) out of the set, \( O( n ) \) time
In pseudocode (section 8.2), \( L \) the list:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{remove}( x ) \cr
2 & \quad \textbf{foreach}\ \text{position } p \text{ of } L
\ \textbf{do}\quad \triangleright\ x \text{ appears once at most} \cr
3 & \qquad \textbf{if}\ L.\mathrm{read}( p ) = x\ \textbf{then}
\ L.\mathrm{remove}( p );\ \textbf{return}
\end{array}}
\]
- Postcondition
- \( x \) is not in the set
◆ size()
template<std::equality_comparable T>
The documentation for this class was generated from the following file: