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

#include <mln/core/internal/set_of.hh>

Public Member Functions

void clear ()
const E & element (unsigned i) const
bool has (const E &elt) const
set_of_< E > & insert (const E &elt)
bool is_empty () const
unsigned nelements () const
set_of_< E > & remove (const E &elt)
const std::vector< E > & vect () const

Protected Member Functions

 set_of_ ()

Protected Attributes

std::set< E > s_

Detailed Description

template<typename E>
class mln::internal::set_of_< E >

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.

Invariant
v_.size() == s_.size() The parameter E is the element type, which shall not be const-qualified.

Definition at line 62 of file set_of.hh.

Constructor & Destructor Documentation

template<typename E>
mln::internal::set_of_< E >::set_of_ ( )
protected

Constructor without arguments.

Member Function Documentation

template<typename E>
void mln::internal::set_of_< E >::clear ( )

Make the set empty.

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

Postcondition
is_empty() == true
template<typename E>
const E& mln::internal::set_of_< E >::element ( 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 E>
bool mln::internal::set_of_< E >::has ( const E &  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 E>
set_of_<E>& mln::internal::set_of_< E >::insert ( const E &  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 E>
bool mln::internal::set_of_< E >::is_empty ( ) const

Test if the set is empty.

template<typename E>
unsigned mln::internal::set_of_< E >::nelements ( ) const

Return the number of elements of the set.

template<typename E>
set_of_<E>& mln::internal::set_of_< E >::remove ( const E &  elt)

Remove an element elt into the set.

Parameters
[in]eltThe element to be deleted.

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

Returns
The set itself after suppression.
template<typename E>
const std::vector<E>& mln::internal::set_of_< E >::vect ( ) const

Give access to the set elements.

The complexity of this method is O(1).

Returns
An array (std::vector) of elements.

Member Data Documentation

template<typename E>
std::set<E> mln::internal::set_of_< E >::s_
protected

Set of elements.

This structure is always up-to-date w.r.t. the set contents.

Definition at line 156 of file set_of.hh.