Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set
// doxy/ or-tools/ src/ util/

operations_research::VectorMap< T > Class Template Reference

This class stores a vector of distinct elements, as well as a map from elements to index to find the index in the vector. More...

#include <vector_map.h>

List of all members.

Public Types

typedef T value_type
 Standard STL container boilerplate.
typedef const T * pointer
typedef const T & reference
typedef const T & const_reference
typedef size_t size_type
typedef ptrdiff_t difference_type
typedef const T * const_iterator
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator

Public Member Functions

int Add (const T &element)
 Adds an element if not already present, and returns its index in the vector-map.
void Add (const std::vector< T > &elements)
int Index (const T &element) const
 Returns -1 if the element is not in the vector, or its unique index if it is.
bool Contains (const T &element) const
const T & Element (int index) const
 Returns the element at position index.
int size () const
 Returns the number of distinct elements added to the vector-map.
void clear ()
 Clears all the elements added to the vector-map.
const std::vector< T > & list () const
 Returns a read-only access to the vector of elements.
const_iterator begin () const
const_iterator end () const
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const

Static Public Attributes

static const size_type npos


Detailed Description

template<class T>
class operations_research::VectorMap< T >

This class stores a vector of distinct elements, as well as a map from elements to index to find the index in the vector.

This is useful to store mapping between objects and indices.

Definition at line 28 of file vector_map.h.


Member Typedef Documentation

template<class T>
typedef T operations_research::VectorMap< T >::value_type

Standard STL container boilerplate.

Definition at line 84 of file vector_map.h.

template<class T>
typedef const T* operations_research::VectorMap< T >::pointer

Definition at line 85 of file vector_map.h.

template<class T>
typedef const T& operations_research::VectorMap< T >::reference

Definition at line 86 of file vector_map.h.

template<class T>
typedef const T& operations_research::VectorMap< T >::const_reference

Definition at line 87 of file vector_map.h.

template<class T>
typedef size_t operations_research::VectorMap< T >::size_type

Definition at line 88 of file vector_map.h.

template<class T>
typedef ptrdiff_t operations_research::VectorMap< T >::difference_type

Definition at line 89 of file vector_map.h.

template<class T>
typedef const T* operations_research::VectorMap< T >::const_iterator

Definition at line 91 of file vector_map.h.

template<class T>
typedef std::reverse_iterator<const_iterator> operations_research::VectorMap< T >::const_reverse_iterator

Definition at line 92 of file vector_map.h.


Member Function Documentation

template<class T>
int operations_research::VectorMap< T >::Add ( const T &  element  )  [inline]

Adds an element if not already present, and returns its index in the vector-map.

Definition at line 32 of file vector_map.h.

template<class T>
void operations_research::VectorMap< T >::Add ( const std::vector< T > &  elements  )  [inline]

Todo:
TODO(user): Use ArraySlice.
Adds all elements of the vector.

Definition at line 46 of file vector_map.h.

template<class T>
int operations_research::VectorMap< T >::Index ( const T &  element  )  const [inline]

Returns -1 if the element is not in the vector, or its unique index if it is.

Definition at line 54 of file vector_map.h.

template<class T>
bool operations_research::VectorMap< T >::Contains ( const T &  element  )  const [inline]

Todo:
TODO(user): explore a int-type version.
Returns wether the element has already been added to the vector-map.

Definition at line 60 of file vector_map.h.

template<class T>
const T& operations_research::VectorMap< T >::Element ( int  index  )  const [inline]

Returns the element at position index.

Definition at line 65 of file vector_map.h.

template<class T>
int operations_research::VectorMap< T >::size (  )  const [inline]

Returns the number of distinct elements added to the vector-map.

Definition at line 72 of file vector_map.h.

template<class T>
void operations_research::VectorMap< T >::clear (  )  [inline]

Clears all the elements added to the vector-map.

Definition at line 75 of file vector_map.h.

template<class T>
const std::vector<T>& operations_research::VectorMap< T >::list (  )  const [inline]

Returns a read-only access to the vector of elements.

Definition at line 81 of file vector_map.h.

template<class T>
const_iterator operations_research::VectorMap< T >::begin (  )  const [inline]

Definition at line 93 of file vector_map.h.

template<class T>
const_iterator operations_research::VectorMap< T >::end (  )  const [inline]

Definition at line 94 of file vector_map.h.

template<class T>
const_reverse_iterator operations_research::VectorMap< T >::rbegin (  )  const [inline]

Definition at line 95 of file vector_map.h.

template<class T>
const_reverse_iterator operations_research::VectorMap< T >::rend (  )  const [inline]

Definition at line 98 of file vector_map.h.


Member Data Documentation

template<class T>
const size_type operations_research::VectorMap< T >::npos [static]

Definition at line 90 of file vector_map.h.


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