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

#include <mln/util/lazy_set.hh>

Public Member Functions

 lazy_set_ ()
void clear ()
const E & element (unsigned i) const
bool get_mode () const
bool has (const E &elt) const
lazy_set_< E > & insert (const E &elt)
bool is_empty () const
unsigned nelements () const
const E & operator[] (unsigned i) const
lazy_set_< E > & remove (const E &elt)
void set_const_mode (bool mode)
const std::vector< E > & vect () const

Public Types

typedef E value

Detailed Description

template<typename E>
class mln::util::lazy_set_< 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 66 of file lazy_set.hh.

Constructor & Destructor Documentation

template<typename E>
mln::util::lazy_set_< E >::lazy_set_ ( )

Constructor without arguments.

Member Function Documentation

template<typename E>
void mln::util::lazy_set_< E >::clear ( )

Make the set empty.

All elements contained in the set are destroyed so the set is emptied. The lazy set can be cleared even if it is in const mode and then it is set in non-const mode.

Postcondition
is_empty() == true
template<typename E>
const E& mln::util::lazy_set_< 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::util::lazy_set_< E >::get_mode ( ) const

Get the mode of the lazy set.

template<typename E>
bool mln::util::lazy_set_< 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>
lazy_set_<E>& mln::util::lazy_set_< 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::util::lazy_set_< E >::is_empty ( ) const

Test if the set is empty.

template<typename E>
unsigned mln::util::lazy_set_< E >::nelements ( ) const

Return the number of elements of the set.

template<typename E>
const E& mln::util::lazy_set_< E >::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 E>
lazy_set_<E>& mln::util::lazy_set_< E >::remove ( const E &  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 E>
void mln::util::lazy_set_< E >::set_const_mode ( bool  mode)

Set the mode of the lazy_set.

The lazy set can have two modes :

  • const : The lazy set is as light as a vector but you cannot modify it
  • non-const : The lazy set use a std::set to have lazy manipulation
Parameters
[in]modeTrue for const mode, false for non-const.
template<typename E>
const std::vector<E>& mln::util::lazy_set_< 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 Typedef Documentation

template<typename E>
typedef E mln::util::lazy_set_< E >::value

Type of the stored value.

Definition at line 71 of file lazy_set.hh.