$extrastylesheet
#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 |
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 parameter E
is the element type, which shall not be const-qualified.
Definition at line 66 of file lazy_set.hh.
mln::util::lazy_set_< E >::lazy_set_ | ( | ) |
Constructor without arguments.
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.
const E& mln::util::lazy_set_< E >::element | ( | unsigned | i | ) | const |
Return the i-th element of the set.
[in] | i | Index of the element to retrieve. |
The element is returned by reference and is constant.
bool mln::util::lazy_set_< E >::get_mode | ( | ) | const |
Get the mode of the lazy set.
bool mln::util::lazy_set_< E >::has | ( | const E & | elt | ) | const |
Test if the object elt
belongs to the set.
[in] | elt | A possible element of the set. |
elt
is in the set. lazy_set_<E>& mln::util::lazy_set_< E >::insert | ( | const E & | elt | ) |
Insert an element elt
into the set.
[in] | elt | The element to be inserted. |
If elt
is already in the set, this method is a no-op.
bool mln::util::lazy_set_< E >::is_empty | ( | ) | const |
Test if the set is empty.
unsigned mln::util::lazy_set_< E >::nelements | ( | ) | const |
Return the number of elements of the set.
const E& mln::util::lazy_set_< E >::operator[] | ( | unsigned | i | ) | const |
Return the i-th element of the set.
[in] | i | Index of the element to retrieve. |
The element is returned by reference and is constant.
lazy_set_<E>& mln::util::lazy_set_< E >::remove | ( | const E & | elt | ) |
Remove an element elt
into the set.
[in] | elt | The element to be inserted. |
If elt
is already in the set, this method is a no-op.
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 :
[in] | mode | True for const mode, false for non-const. |
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).
typedef E mln::util::lazy_set_< E >::value |
Type of the stored value.
Definition at line 71 of file lazy_set.hh.