DGtal  0.9.4beta
Data Structures | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::LabelledMap< TData, L, TWord, N, M > Class Template Reference

#include <DGtal/base/LabelledMap.h>

Inheritance diagram for DGtal::LabelledMap< TData, L, TWord, N, M >:
[legend]
Collaboration diagram for DGtal::LabelledMap< TData, L, TWord, N, M >:
[legend]

Data Structures

struct  __AnyBlock
 
struct  __FirstBlock
 
class  BlockConstIterator
 
class  BlockIterator
 
union  BlockPointer
 
class  ConstIterator
 
union  DataOrBlockPointer
 
class  KeyCompare
 
class  ValueCompare
 

Public Types

typedef LabelledMap< TData, L, TWord, N, M > Self
 
typedef TData Data
 
typedef TWord Word
 
typedef Labels< L, WordLabelsType
 
typedef LabelsType::Label Label
 
typedef Label Key
 
typedef std::pair< const Key, DataValue
 
typedef LabelsType::ConstIterator LabelsConstIterator
 
typedef std::ptrdiff_t DifferenceType
 
typedef std::size_t SizeType
 
typedef ValueReference
 
typedef ValuePointer
 
typedef const ValueConstReference
 
typedef const ValueConstPointer
 
typedef Key key_type
 
typedef Value value_type
 
typedef Data data_type
 
typedef Data mapped_type
 
typedef DifferenceType difference_type
 
typedef Reference reference
 
typedef Pointer pointer
 
typedef ConstReference const_reference
 
typedef ConstPointer const_pointer
 
typedef SizeType size_type
 
typedef ConstIterator iterator
 
typedef ConstIterator const_iterator
 
typedef KeyCompare key_compare
 
typedef ValueCompare value_compare
 
typedef ConstIterator Iterator
 

Public Member Functions

 LabelledMap ()
 
 LabelledMap (const LabelledMap &other)
 
template<typename InputIterator >
 LabelledMap (InputIterator first, InputIterator last)
 
LabelledMapoperator= (const LabelledMap &other)
 
 ~LabelledMap ()
 
const LabelsTypelabels () const
 
SizeType size () const
 
bool empty () const
 
SizeType max_size () const
 
SizeType capacity () const
 
KeyCompare key_comp () const
 
ValueCompare value_comp () const
 
void swap (Self &other)
 
void clear ()
 
SizeType count (const Key &key) const
 
Dataoperator[] (const Key &key)
 
const Dataoperator[] (const Key &key) const
 
DatafastAt (const Key &key)
 
const DatafastAt (const Key &key) const
 
std::pair< Iterator, bool > insert (const Value &val)
 
Iterator insert (Iterator position, const Value &val)
 
template<typename InputIterator >
void insert (InputIterator first, InputIterator last)
 
void erase (Iterator position)
 
SizeType erase (Key key)
 
void erase (Iterator first, Iterator last)
 
ConstIterator begin () const
 
ConstIterator end () const
 
Iterator begin ()
 
Iterator end ()
 
std::pair< Iterator, Iteratorequal_range (const Key &x)
 
std::pair< ConstIterator, ConstIteratorequal_range (const Key &x) const
 
Iterator find (const Key &x)
 
ConstIterator find (const Key &x) const
 
Iterator lower_bound (const Key &x)
 
ConstIterator lower_bound (const Key &x) const
 
Iterator upper_bound (const Key &x)
 
ConstIterator upper_bound (const Key &x) const
 
void blockClear (unsigned int size)
 
DatablockAt (unsigned int idx)
 
const DatablockAt (unsigned int idx) const
 
DatablockInsert (unsigned int idx, unsigned int block_size, const Data &data)
 
void blockErase (unsigned int idx)
 
BlockIterator blockBegin ()
 
BlockIterator blockEnd ()
 
BlockConstIterator blockBegin () const
 
BlockConstIterator blockEnd () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Member Functions

 BOOST_STATIC_ASSERT (L >=1)
 
 BOOST_STATIC_ASSERT (N >=0)
 
 BOOST_STATIC_ASSERT (M >=2)
 

Private Attributes

LabelsType myLabels
 
__FirstBlock myFirstBlock
 

Detailed Description

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
class DGtal::LabelledMap< TData, L, TWord, N, M >

Aim: Represents a map label -> data, where the label is an integer between 0 and a constant L-1. It is based on a binary coding of labels and a mixed list/array structure. The assumption is that the number of used labels is much less than L. The objective is to minimize the memory usage.

Description of template class 'LabelledMap'

Model of boost::AssociativeContainer, boost::PairAssociativeContainer, boost::UniqueAssociativeContainer. As such, it is refinement of boost::ForwardContainer and boost::Container. It is also a model of boost::Assignable, boost::CopyConstructible.

V[ 0 ] is the data of the first set label.
V[ 1 ] is the data of the second set label.
...

if less than 4 datas and N = 3
+------+------+------+------+------+
|labels| V[0] | V[1] | ...  |  0   |
+------+------+------+------+------+

if only 4 datas and N = 3
+------+------+------+------+------+
|labels| V[0] | V[1] | V[2] | V[3] |
+------+------+------+------+------+

if more than 4 datas and N = 3, M = 4
+------+------+------+------+------+        +------+------+------+------+------+
|labels| V[0] | V[1] | V[2] | ptr --------> | V[3] | V[4] | V[5] | V[6] | ptr --------> ...
+------+------+------+------+------+        +------+------+------+------+------+

This structure is related to the IndexedListWithBlocks, except that it stores the mapping label -> index. The (maximum) number of possible labels is fixed at instantiation for optimisation purposes.

Such a structure is useful when:

Model of boost::PairAssociativeContainer and boost::SimpleAssociativeContainer.

Template Parameters
TDatathe type for the datas stored in the list.
Lthe maximum number of labels.
TWordthe integer used to store the labels (if L >= log_2( digits( TWord ) ) then several consecutive words are stored.), e.g. DGtal::uint8_t.
Nthe number of data stored in the first block.
Mthe number of data stored in the further blocks.

NB: In the following, we use the notations

Definition at line 119 of file LabelledMap.h.

Member Typedef Documentation

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::const_iterator

Definition at line 159 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef ConstPointer DGtal::LabelledMap< TData, L, TWord, N, M >::const_pointer

Definition at line 156 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef ConstReference DGtal::LabelledMap< TData, L, TWord, N, M >::const_reference

Definition at line 155 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef const Value* DGtal::LabelledMap< TData, L, TWord, N, M >::ConstPointer

Definition at line 141 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef const Value& DGtal::LabelledMap< TData, L, TWord, N, M >::ConstReference

Definition at line 140 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef TData DGtal::LabelledMap< TData, L, TWord, N, M >::Data

Definition at line 127 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Data DGtal::LabelledMap< TData, L, TWord, N, M >::data_type

Definition at line 150 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef DifferenceType DGtal::LabelledMap< TData, L, TWord, N, M >::difference_type

Definition at line 152 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef std::ptrdiff_t DGtal::LabelledMap< TData, L, TWord, N, M >::DifferenceType

Definition at line 136 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::iterator

Definition at line 158 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::Iterator

non-mutable class via iterators.

Definition at line 730 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Label DGtal::LabelledMap< TData, L, TWord, N, M >::Key

Definition at line 131 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef KeyCompare DGtal::LabelledMap< TData, L, TWord, N, M >::key_compare

Definition at line 160 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Key DGtal::LabelledMap< TData, L, TWord, N, M >::key_type

Forward declaration.

Definition at line 146 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef LabelsType::Label DGtal::LabelledMap< TData, L, TWord, N, M >::Label

Definition at line 130 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef LabelsType::ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::LabelsConstIterator

Definition at line 135 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Labels<L, Word> DGtal::LabelledMap< TData, L, TWord, N, M >::LabelsType

Definition at line 129 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Data DGtal::LabelledMap< TData, L, TWord, N, M >::mapped_type

Definition at line 151 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Value* DGtal::LabelledMap< TData, L, TWord, N, M >::Pointer

Definition at line 139 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Pointer DGtal::LabelledMap< TData, L, TWord, N, M >::pointer

Definition at line 154 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Value& DGtal::LabelledMap< TData, L, TWord, N, M >::Reference

Definition at line 138 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Reference DGtal::LabelledMap< TData, L, TWord, N, M >::reference

Definition at line 153 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef LabelledMap<TData, L, TWord, N, M> DGtal::LabelledMap< TData, L, TWord, N, M >::Self

Definition at line 126 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef SizeType DGtal::LabelledMap< TData, L, TWord, N, M >::size_type

Definition at line 157 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef std::size_t DGtal::LabelledMap< TData, L, TWord, N, M >::SizeType

Definition at line 137 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef std::pair<const Key, Data> DGtal::LabelledMap< TData, L, TWord, N, M >::Value

Definition at line 132 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef ValueCompare DGtal::LabelledMap< TData, L, TWord, N, M >::value_compare

Definition at line 161 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef Value DGtal::LabelledMap< TData, L, TWord, N, M >::value_type

Definition at line 149 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
typedef TWord DGtal::LabelledMap< TData, L, TWord, N, M >::Word

Definition at line 128 of file LabelledMap.h.

Constructor & Destructor Documentation

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::LabelledMap ( )

Constructor.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::LabelledMap ( const LabelledMap< TData, L, TWord, N, M > &  other)

Copy constructor.

Parameters
otherthe object to clone.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
template<typename InputIterator >
DGtal::LabelledMap< TData, L, TWord, N, M >::LabelledMap ( InputIterator  first,
InputIterator  last 
)

Constructor from range.

Template Parameters
InputIteratormodel of boost::InputIterator whose value type is convertible to Value.
Parameters
firstan iterator on the first value of the range.
lastan iterator after the last value of the range.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::~LabelledMap ( )

Destructor.

Member Function Documentation

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::begin ( ) const
Returns
an iterator pointing on the first element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Iterator DGtal::LabelledMap< TData, L, TWord, N, M >::begin ( )
Returns
an iterator pointing on the first element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Data& DGtal::LabelledMap< TData, L, TWord, N, M >::blockAt ( unsigned int  idx)

Random unprotected read-write access to data at position idx

Parameters
idxthe index of the data in the container.
Returns
a reference on the data.
Precondition
idx < size() NB: O( b ), E = O( 1 + ceil( ( idx - N ) / M ) )
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
const Data& DGtal::LabelledMap< TData, L, TWord, N, M >::blockAt ( unsigned int  idx) const

Random unprotected read access to data at position idx

Parameters
idxthe index of the data in the container.
Returns
a const reference on the data.
Precondition
idx < size() NB: O( b ), E = O( 1 + ceil( ( idx - N ) / M ) )
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
BlockIterator DGtal::LabelledMap< TData, L, TWord, N, M >::blockBegin ( )
Returns
an iterator pointing on the first element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
BlockConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::blockBegin ( ) const
Returns
an iterator pointing on the first element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::blockClear ( unsigned int  size)

Removes all the datas stored in the block structure.

Parameters
sizemust be the current size of the block structure.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
BlockIterator DGtal::LabelledMap< TData, L, TWord, N, M >::blockEnd ( )
Returns
an iterator pointing after the last element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
BlockConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::blockEnd ( ) const
Returns
an iterator pointing after the last element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::blockErase ( unsigned int  idx)

Removal of a data at a given position. Following datas are shifted.

Parameters
idxthe index of the data in the container.
Precondition
idx < size() NB: O( n ), E = O( n - idx )
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Data& DGtal::LabelledMap< TData, L, TWord, N, M >::blockInsert ( unsigned int  idx,
unsigned int  block_size,
const Data data 
)

Insertion of a new data at given position. The former data at this position and the next ones are shifted.

Parameters
idxthe index of the data in the container.
Precondition
idx <= size() (if size(), inserts at the end.
Parameters
block_sizethe block size.
datathe data to insert. NB: O( n ), E = O( n - idx )
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BOOST_STATIC_ASSERT ( L >=  1)
private
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BOOST_STATIC_ASSERT ( N >=  0)
private
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
DGtal::LabelledMap< TData, L, TWord, N, M >::BOOST_STATIC_ASSERT ( M >=  2)
private
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
SizeType DGtal::LabelledMap< TData, L, TWord, N, M >::capacity ( ) const

The number of datas currently allocated in the structure.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::clear ( )

Removes all the datas stored in the structure.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
SizeType DGtal::LabelledMap< TData, L, TWord, N, M >::count ( const Key key) const

Follows std::count.

Parameters
keyany label
Returns
0 if the key is not present in container, 1 otherwise.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
bool DGtal::LabelledMap< TData, L, TWord, N, M >::empty ( ) const
Returns
'true' if and only if the container is empty. O(1)
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::end ( ) const
Returns
an iterator pointing after the last element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Iterator DGtal::LabelledMap< TData, L, TWord, N, M >::end ( )
Returns
an iterator pointing after the last element in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
std::pair<Iterator, Iterator> DGtal::LabelledMap< TData, L, TWord, N, M >::equal_range ( const Key x)

Get range of equal elements.

Returns the bounds of a range that includes all the elements in the container with a key that compares equal to x. Here, the range will include one element at most.

If x does not match any key in the container, the range returned has a length of zero, with both iterators pointing to the element with nearest key greater than x, if any, or to map::end if x is greater than all the elements in the container.

Parameters
xany key in 0..L-1
Returns
a pair, where its member pair::first is an iterator to the lower bound of the range with the same value as the one that would be returned by lower_bound(x), and pair::second is an iterator to the upper bound of the range with the same value as the one that would be returned by upper_bound(x).
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
std::pair<ConstIterator, ConstIterator> DGtal::LabelledMap< TData, L, TWord, N, M >::equal_range ( const Key x) const

Get range of equal elements.

Returns the bounds of a range that includes all the elements in the container with a key that compares equal to x. Here, the range will include one element at most.

If x does not match any key in the container, the range returned has a length of zero, with both iterators pointing to the element with nearest key greater than x, if any, or to map::end if x is greater than all the elements in the container.

Parameters
xany key in 0..L-1
Returns
a pair, where its member pair::first is an iterator to the lower bound of the range with the same value as the one that would be returned by lower_bound(x), and pair::second is an iterator to the upper bound of the range with the same value as the one that would be returned by upper_bound(x).
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::erase ( Iterator  position)

Erases the pair (key,data) pointed by iterator.

Parameters
positionany valid iterator in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
SizeType DGtal::LabelledMap< TData, L, TWord, N, M >::erase ( Key  key)

Erases the element of key key.

Parameters
keyany key (in 0..L-1)
Returns
the number of elements deleted (0 or 1).
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::erase ( Iterator  first,
Iterator  last 
)

Erases the elements in the range [first,last).

Parameters
firsta valid iterator.
lasta valid iterator.

NB: to clear the container, prefer clear() instead of erase( begin(), end() ).

See also
clear
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Data& DGtal::LabelledMap< TData, L, TWord, N, M >::fastAt ( const Key key)

A read-write accessor to the data associated to an existing key.

Parameters
keyany label (such that count(key)==1)
Returns
a reference to the associated data.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
const Data& DGtal::LabelledMap< TData, L, TWord, N, M >::fastAt ( const Key key) const

A read-only accessor to the data associated to an existing key.

Parameters
keyany label (such that count(key)==1)
Returns
a const reference to the associated data.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Iterator DGtal::LabelledMap< TData, L, TWord, N, M >::find ( const Key x)

Get iterator to element.

Searches the container for an element with x as key and returns an iterator to it if found, otherwise it returns an iterator to end() (the element past the end of the container).

NB: Another member function, count(), can be used to just check whether a particular key exists. 'count( x ) == 1' is faster than 'find( x ) != end()'.

Parameters
xKey to be searched for (in 0..L-1)
Returns
An iterator to the element, if the specified key value is found, end() if the specified key is not found in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::find ( const Key x) const

Get iterator to element.

Searches the container for an element with x as key and returns an iterator to it if found, otherwise it returns an iterator to end() (the element past the end of the container).

NB: Another member function, count(), can be used to just check whether a particular key exists. 'count( x ) == 1' is faster than 'find( x ) != end()'.

Parameters
xKey to be searched for (in 0..L-1)
Returns
An iterator to the element, if the specified key value is found, end() if the specified key is not found in the container.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
std::pair<Iterator, bool> DGtal::LabelledMap< TData, L, TWord, N, M >::insert ( const Value val)

Insertion of a new data at given label. Follows std::insert return a pair<iterator,bool>). Note that the data is associated to key only if key was not present in the container.

Parameters
vala pair<key,data>.
Returns
a pair <iterator,bool> where iterator points on the pair (key,data) while the boolean is true if a new element was indeed created.

NB: This method is provided to follow the std::AssociativeContainer concept. You are discourage to use this functions since the correct iterator must be recomputed at each insert. Prefer operator[] or fastAt.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Iterator DGtal::LabelledMap< TData, L, TWord, N, M >::insert ( Iterator  position,
const Value val 
)

Inserts the pair val (key,data) in the container, where position is a hint

Parameters
positionan iterator used as a hint to find the good place. Unused here.
vala pair (key,data)
Returns
an iterator on the inserted element.

NB: This method is provided to follow the std::AssociativeContainer concept. You are discourage to use this functions since the correct iterator must be recomputed at each insert. Prefer operator[] or fastAt.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
template<typename InputIterator >
void DGtal::LabelledMap< TData, L, TWord, N, M >::insert ( InputIterator  first,
InputIterator  last 
)

Insertion from range. Insert all values in the range. Be careful that if a value in the container has the same key as a value in the range, then the mapped data is not changed.

Template Parameters
InputIteratormodel of boost::InputIterator whose value type is convertible to Value.
Parameters
firstan iterator on the first value of the range.
lastan iterator after the last value of the range.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
bool DGtal::LabelledMap< TData, L, TWord, N, M >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
KeyCompare DGtal::LabelledMap< TData, L, TWord, N, M >::key_comp ( ) const
Returns
a comparator object for two keys. Corresponds to k1 < k2.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
const LabelsType& DGtal::LabelledMap< TData, L, TWord, N, M >::labels ( ) const
Returns
a reference to the labels.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Iterator DGtal::LabelledMap< TData, L, TWord, N, M >::lower_bound ( const Key x)

Return iterator to lower bound.

Returns an iterator pointing to the first element in the container whose key does not compare less than x (using the container's comparison object), i.e. it is either equal or greater.

Unlike upper_bound(), this member function returns an iterator to the element also if it compares equal to x and not only if it compares greater.

Notice that, internally, all the elements in this container are always ordered by their keys, therefore all the elements that follow the one returned by this function will have a key that compares greater than x.

Parameters
xKey to be searched for (in 0..L-1)
Returns
an iterator to the the first element in the container whose key does not compare less than x.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::lower_bound ( const Key x) const

Return iterator to lower bound.

Returns an iterator pointing to the first element in the container whose key does not compare less than x, i.e. it is either equal or greater.

Unlike upper_bound(), this member function returns an iterator to the element also if it compares equal to x and not only if it compares greater.

Notice that, internally, all the elements in this container are always ordered by their keys, therefore all the elements that follow the one returned by this function will have a key that compares greater than x.

Parameters
xKey to be searched for (in 0..L-1)
Returns
an iterator to the the first element in the container whose key does not compare less than x.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
SizeType DGtal::LabelledMap< TData, L, TWord, N, M >::max_size ( ) const

The maximum number of datas storable in the structure.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
LabelledMap& DGtal::LabelledMap< TData, L, TWord, N, M >::operator= ( const LabelledMap< TData, L, TWord, N, M > &  other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Data& DGtal::LabelledMap< TData, L, TWord, N, M >::operator[] ( const Key key)

Follows std::operator[]. Given a key key, returns a reference to the associated data.

Parameters
keyany label
Returns
a reference to the associated data.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
const Data& DGtal::LabelledMap< TData, L, TWord, N, M >::operator[] ( const Key key) const

Read-only version. Follows std::operator[]. Given a key key, returns a reference to the associated data.

Parameters
keyany label
Returns
a const reference to the associated data.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
SizeType DGtal::LabelledMap< TData, L, TWord, N, M >::size ( ) const

The number of datas stored in the structure. O(1) complexity.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
void DGtal::LabelledMap< TData, L, TWord, N, M >::swap ( Self other)

Swap content. Exchanges the content of the container with the content of mp, which is another map object containing elements of the same type. Sizes may differ.

After the call to this member function, the elements in this container are those which were in mp before the call, and the elements of mp are those which were in this.

NB: not exactly standard ! The iterators pointing on the first block change roles ! The other references and pointers remain valid for the swapped objects.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
Iterator DGtal::LabelledMap< TData, L, TWord, N, M >::upper_bound ( const Key x)

Return iterator to upper bound.

Returns an iterator pointing to the first element in the container whose key compares greater than x. (>x)

Unlike lower_bound(), this member function does not return an iterator to the element if its key compares equal to x, but only if it compares strictly greater.

Notice that, internally, all the elements in this container are always ordered by their keys, therefore all the elements that follow the one returned by this function will have a key that compares greater than x.

Parameters
xKey to be searched for (in 0..L-1)
Returns
an iterator to the the first element in the container whose key compares greater than x.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
ConstIterator DGtal::LabelledMap< TData, L, TWord, N, M >::upper_bound ( const Key x) const

Return iterator to upper bound.

Returns an iterator pointing to the first element in the container whose key compares greater than x. (>x)

Unlike lower_bound(), this member function does not return an iterator to the element if its key compares equal to x, but only if it compares strictly greater.

Notice that, internally, all the elements in this container are always ordered by their keys, therefore all the elements that follow the one returned by this function will have a key that compares greater than x.

Parameters
xKey to be searched for (in 0..L-1)
Returns
an iterator to the the first element in the container whose key compares greater than x.
template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
ValueCompare DGtal::LabelledMap< TData, L, TWord, N, M >::value_comp ( ) const
Returns
a comparator object for two values. Corresponds to v1.first < v2.first.

Field Documentation

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
__FirstBlock DGtal::LabelledMap< TData, L, TWord, N, M >::myFirstBlock
private

Stores the first block of datas.

Definition at line 1234 of file LabelledMap.h.

template<typename TData, unsigned int L, typename TWord, unsigned int N, unsigned int M>
LabelsType DGtal::LabelledMap< TData, L, TWord, N, M >::myLabels
private

Stores the labels for this sequence of datas.

Definition at line 1229 of file LabelledMap.h.


The documentation for this class was generated from the following file: