Base Framework
Classes | Public Types | Public Member Functions | Related Functions | List of all members
Set< KEY > Class Template Reference

Set collection. More...

#include <base/collection/Set.h>

Inherits Collection.

Classes

class  NodePredicate
 
class  SetEnumerator
 

Public Types

typedef OrderedBinaryTree< KEY > Tree
 
typedef SetEnumerator< EnumeratorTraits< KEY >, typename Tree::EnumeratorEnumerator
 
typedef SetEnumerator< ReadEnumeratorTraits< KEY >, typename Tree::ReadEnumeratorReadEnumerator
 
typedef Tree::Iterator Iterator
 
typedef Tree::ReadIterator ReadIterator
 

Public Member Functions

 Set () noexcept
 
 Set (std::initializer_list< KEY > values)
 
 Set (const Set &copy) noexcept
 
MemorySize getSize () const noexcept
 
bool isEmpty () const noexcept
 
Enumerator getEnumerator () noexcept
 
ReadEnumerator getReadEnumerator () const noexcept
 
bool hasKey (const KEY &key) const noexcept
 
const KEY * find (const KEY &key) const noexcept
 
void rebalance ()
 
const KEY * add (const KEY &key)
 
void remove (const KEY &key)
 
void remove (const Iterator &it)
 
template<class PREDICATE >
void removeByPredicate (PREDICATE predicate)
 
void removeAll () noexcept
 
 operator bool () const noexcept
 
const KEY & operator[] (const KEY &key) const
 
const TreegetTree () const noexcept
 
Iterator begin () noexcept
 
Iterator end () noexcept
 
ReadIterator begin () const noexcept
 
ReadIterator end () const noexcept
 
Setoperator<< (const KEY &key)
 
Setoperator<< (KEY &&key)
 

Related Functions

(Note that these are not member functions.)

template<class TYPE >
FormatOutputStreamoperator<< (FormatOutputStream &stream, const Set< TYPE > &value)
 

Detailed Description

template<class KEY>
class Set< KEY >

Set collection.

Set collection implemented using an ordered binary tree.

Version
1.1
Examples
testsuite/Set.cpp.

Member Typedef Documentation

◆ Enumerator

template<class KEY >
typedef SetEnumerator<EnumeratorTraits<KEY>, typename Tree::Enumerator> Set< KEY >::Enumerator

Modifying enumerator.

◆ ReadEnumerator

template<class KEY >
typedef SetEnumerator<ReadEnumeratorTraits<KEY>, typename Tree::ReadEnumerator> Set< KEY >::ReadEnumerator

Non-modifying enumerator.

Constructor & Destructor Documentation

◆ Set() [1/2]

template<class KEY >
Set< KEY >::Set ( )
inlinenoexcept

Initializes an empty set.

◆ Set() [2/2]

template<class KEY >
Set< KEY >::Set ( const Set< KEY > &  copy)
inlinenoexcept

Initializes set from other set.

Member Function Documentation

◆ add()

template<class KEY >
const KEY* Set< KEY >::add ( const KEY &  key)
inline

Adds the specified key to the set.

Parameters
keyThe key to be added to the set.

◆ find()

template<class KEY >
const KEY* Set< KEY >::find ( const KEY &  key) const
inlinenoexcept

Returns the key for the specified key. This makes sense when you need the actual state of the key which might not be used for comparison.

Parameters
keyThe key.
Returns
nullptr is key doesn't exist.

◆ getEnumerator()

template<class KEY >
Enumerator Set< KEY >::getEnumerator ( )
inlinenoexcept

Returns a modifying enumerator of the ordered binary tree.

◆ getReadEnumerator()

template<class KEY >
ReadEnumerator Set< KEY >::getReadEnumerator ( ) const
inlinenoexcept

Returns a non-modifying enumerator of the ordered binary tree.

◆ getSize()

template<class KEY >
MemorySize Set< KEY >::getSize ( ) const
inlinenoexcept

Returns the number of elements in the collection.

◆ hasKey()

template<class KEY >
bool Set< KEY >::hasKey ( const KEY &  key) const
inlinenoexcept

Returns true if the specified key is present is this set.

Parameters
keyThe value to search for.

◆ isEmpty()

template<class KEY >
bool Set< KEY >::isEmpty ( ) const
inlinenoexcept

Returns true if the collection is empty.

◆ operator<<() [1/2]

template<class KEY >
Set& Set< KEY >::operator<< ( const KEY &  key)
inline

Adds value.

◆ operator<<() [2/2]

template<class KEY >
Set& Set< KEY >::operator<< ( KEY &&  key)
inline

Adds value.

◆ operator[]()

template<class KEY >
const KEY& Set< KEY >::operator[] ( const KEY &  key) const
inline

Returns the key for the specified key. Makes sense when you need to use the key as a reference.

◆ remove()

template<class KEY >
void Set< KEY >::remove ( const KEY &  key)
inline

Removes the specified key from this set. Raises InvalidNode if the key doesn't exist in the set.

Parameters
keyThe value to be removed from the set.

◆ removeAll()

template<class KEY >
void Set< KEY >::removeAll ( )
inlinenoexcept

Removes all the keys from this set.

Friends And Related Function Documentation

◆ operator<<()

template<class TYPE >
FormatOutputStream & operator<< ( FormatOutputStream stream,
const Set< TYPE > &  value 
)
related

Writes a string representation of a set to a format stream.