$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mln::util::set< T > Class Template Reference

#include <mln/util/set.hh>

Public Member Functions

 set ()
void clear ()
const T first_element () const
bool has (const T &elt) const
set< T > & insert (const T &elt)
template<typename U >
set< T > & insert (const set< U > &other)
bool is_empty () const
bool is_frozen_ () const
const T last_element () const
std::size_t memory_size () const
unsigned nelements () const
const Toperator[] (unsigned i) const
set< T > & remove (const T &elt)
const std::vector< T > & std_vector () const

Public Types

typedef set_bkd_iter< Tbkd_eiter
typedef Object< void > category
typedef fwd_eiter eiter
typedef T element
typedef mln::util::set< Texact_t
typedef set_fwd_iter< Tfwd_eiter

Detailed Description

template<typename T>
class mln::util::set< T >

An "efficient" mathematical set class.

This set class is designed to store a mathematical set and to present it to the user as a linear array (std::vector).

Elements are stored by copy. Implementation is lazy.

The set has two states: frozen or not. There is an automatic switch of state when the user modifies its contents (insert, remove, or clear) or access to its contents (op[i]).

The parameter T is the element type, which shall not be const-qualified.

The unicity (and the order) of set elements is handled by the mln::util::ord mechanism.

See Also
mln::util::ord

Definition at line 81 of file util/set.hh.

Constructor & Destructor Documentation

template<typename T>
mln::util::set< T >::set ( )

Constructor without arguments.

Member Function Documentation

template<typename T>
void mln::util::set< T >::clear ( )

Empty the set.

All elements contained in the set are destroyed so the set is emptied.

Postcondition
is_empty() == true
template<typename T>
const T mln::util::set< T >::first_element ( ) const

Return the first element of the set.

Precondition
not is_empty()
template<typename T>
bool mln::util::set< T >::has ( const T elt) const

Test if the object elt belongs to the set.

Parameters
[in]eltA possible element of the set.
Returns
True is elt is in the set.
template<typename T>
set<T>& mln::util::set< T >::insert ( const T elt)

Insert an element elt into the set.

Parameters
[in]eltThe element to be inserted.

If elt is already in the set, this method is a no-op.

Returns
The set itself after insertion.
template<typename T>
template<typename U >
set<T>& mln::util::set< T >::insert ( const set< U > &  other)

Insert the elements of other into the set.

Parameters
[in]otherThe set containing the elements to be inserted.
Returns
The set itself after insertion.
template<typename T>
bool mln::util::set< T >::is_empty ( ) const

Test if the set is empty.

template<typename T>
bool mln::util::set< T >::is_frozen_ ( ) const

Test if the set is frozen.

template<typename T>
const T mln::util::set< T >::last_element ( ) const

Return the last element of the set.

Precondition
not is_empty()
template<typename T>
std::size_t mln::util::set< T >::memory_size ( ) const

Return the size of this set in memory.

template<typename T>
unsigned mln::util::set< T >::nelements ( ) const

Return the number of elements of the set.

template<typename T>
const T& mln::util::set< T >::operator[] ( unsigned  i) const

Return the i-th element of the set.

Parameters
[in]iIndex of the element to retrieve.
Precondition
i < nelements()

The element is returned by reference and is constant.

template<typename T>
set<T>& mln::util::set< T >::remove ( const T elt)

Remove an element elt into the set.

Parameters
[in]eltThe element to be inserted.

If elt is already in the set, this method is a no-op.

Returns
The set itself after suppression.
template<typename T>
const std::vector<T>& mln::util::set< T >::std_vector ( ) const

Give access to the set elements.

The complexity of this method is O(1).

Postcondition
The set is frozen.
Returns
An array (std::vector) of elements.

Member Typedef Documentation

template<typename T>
typedef set_bkd_iter<T> mln::util::set< T >::bkd_eiter

Backward iterator associated type.

Definition at line 93 of file util/set.hh.

typedef Object<void> mln::Object< mln::util::set< T > >::category
inherited

Definition at line 106 of file object.hh.

template<typename T>
typedef fwd_eiter mln::util::set< T >::eiter

Iterator associated type.

Definition at line 96 of file util/set.hh.

template<typename T>
typedef T mln::util::set< T >::element

Element associated type.

Definition at line 86 of file util/set.hh.

typedef mln::util::set< T > mln::Object< mln::util::set< T > >::exact_t
inherited

Definition at line 105 of file object.hh.

template<typename T>
typedef set_fwd_iter<T> mln::util::set< T >::fwd_eiter

Forward iterator associated type.

Definition at line 90 of file util/set.hh.