public

Inheritance Graph

graph BT
	BidirectionalMap
	click BidirectionalMap "classUtil_1_1BidirectionalMap"

Description

Class for storing bidirectional mappings between objects. The types of the used maps are given as template parameters. If the types of the values differ for the two maps (e.g. leftToRight: int -> Object* rightToLeft: int <- Reference), corresponding conversion functors may have to be given as additional parameters (if an implicit conversion is not available)

// leftToRight: int -> Util::Bitmap*
// rightToLeft: int <- Util::Reference<Util::Bitmap>
// the additional conversion parameters are necessary as there is no implicit cast from Util::Reference<Util::Bitmap> to Util::Bitmap*
typedef Util::BidirectionalMap<
                std::unordered_map<int, Util::Bitmap*>,
                std::unordered_map<Util::Reference<Util::Bitmap> , int, Util::BidirectionalMapPolicies::hashByGet>,
                    Util::BidirectionalMapPolicies::convertByIdentity,  // convert_leftKeyToRightMapped_t: int -> int
                Util::BidirectionalMapPolicies::convertByIdentity,  // convert_rightMappedToLeftKey_t: int <- int
                Util::BidirectionalMapPolicies::convertByGet,       // convert_leftMappedToRightKey_t: Reference -> Bitmap*
                Util::BidirectionalMapPolicies::convertByIdentity   // convert_rightKeyToLeftMapped_t: Reference <- Bitmap*
                >   bitmapRegistry_t;

Note: All iterators are const_iterators to ensure that both internal maps stay consistent.

Note: Have a look at BidirectionalUnorderedMap , which should be what you are looking for in most cases.

Public Types

   
   
typedef map_leftToRight_t::key_type leftToRight_key_t
   
typedef map_leftToRight_t::value_type leftToRight_value_t
   
typedef map_leftToRight_t::mapped_type leftToRight_mapped_t
   
typedef map_rightToLeft_t::key_type rightToLeft_key_t
   
typedef map_rightToLeft_t::value_type rightToLeft_value_t
   
typedef map_rightToLeft_t::mapped_type rightToLeft_mapped_t
   
typedef map_leftToRight_t::size_type size_type
the size type of this map
   
typedef map_leftToRight_t::value_type value_type
pair of left and right value
   
typedef map_leftToRight_t::const_iterator const_iterator_left
const_iterator for the left to right mapping
   
typedef map_rightToLeft_t::const_iterator const_iterator_right
const_iterator for the right to left mapping
   
typedef const_iterator_left iterator_left
   
typedef const_iterator_right iterator_right

Public Functions

   
   
  BidirectionalMap()
ctor, constructs an empty map
   
  BidirectionalMap(const BidirectionalMap & other)
   
  ~BidirectionalMap()
dtor
   
BidirectionalMap & operator=(const BidirectionalMap & other)
assignment operator, assigns the content of other map to this map
   
const_iterator_left beginLeft() const
   
const_iterator_right beginRight() const
   
void clear()
removes all enties from the map
   
bool empty() const
   
const_iterator_left endLeft() const
   
const_iterator_right endRight() const
   
const_iterator_left eraseLeft(const const_iterator_left & _left)
   
const_iterator_right eraseRight(const const_iterator_right & _right)
   
size_type eraseLeft(const leftToRight_key_t & _left)
   
size_type eraseRight(const rightToLeft_key_t & _right)
   
const_iterator_left findLeft(const leftToRight_key_t & _left) const
   
const_iterator_right findRight(const rightToLeft_key_t & _right) const
   
bool insert(const value_type & x)
   
bool insert(const leftToRight_key_t & _left, const rightToLeft_key_t & _right)
   
size_type max_Size()
   
size_type size() const
   
void swap( BidirectionalMap & other)

Documentation

typedef
Util::BidirectionalMap::leftToRight_key_t

public
 
 
typedef map_leftToRight_t::key_type leftToRight_key_t

Defined in Util/BidirectionalMap.h:102


typedef
Util::BidirectionalMap::leftToRight_value_t

public
 
 
typedef map_leftToRight_t::value_type leftToRight_value_t

Defined in Util/BidirectionalMap.h:103


typedef
Util::BidirectionalMap::leftToRight_mapped_t

public
 
 
typedef map_leftToRight_t::mapped_type leftToRight_mapped_t

Defined in Util/BidirectionalMap.h:104


typedef
Util::BidirectionalMap::rightToLeft_key_t

public
 
 
typedef map_rightToLeft_t::key_type rightToLeft_key_t

Defined in Util/BidirectionalMap.h:106


typedef
Util::BidirectionalMap::rightToLeft_value_t

public
 
 
typedef map_rightToLeft_t::value_type rightToLeft_value_t

Defined in Util/BidirectionalMap.h:107


typedef
Util::BidirectionalMap::rightToLeft_mapped_t

public
 
 
typedef map_rightToLeft_t::mapped_type rightToLeft_mapped_t

Defined in Util/BidirectionalMap.h:108


typedef
Util::BidirectionalMap::size_type

public
 
 
typedef map_leftToRight_t::size_type size_type

the size type of this map

Defined in Util/BidirectionalMap.h:112


typedef
Util::BidirectionalMap::value_type

public
 
 
typedef map_leftToRight_t::value_type value_type

pair of left and right value

Defined in Util/BidirectionalMap.h:115


typedef
Util::BidirectionalMap::const_iterator_left

public
 
 
typedef map_leftToRight_t::const_iterator const_iterator_left

const_iterator for the left to right mapping

Defined in Util/BidirectionalMap.h:118


typedef
Util::BidirectionalMap::const_iterator_right

public
 
 
typedef map_rightToLeft_t::const_iterator const_iterator_right

const_iterator for the right to left mapping

Defined in Util/BidirectionalMap.h:121


typedef
Util::BidirectionalMap::iterator_left

public
 
 
typedef const_iterator_left iterator_left

normal iterator only declared for convenience, they are also const because otherwise it would be possible to change only one of the internal maps

Defined in Util/BidirectionalMap.h:126


typedef
Util::BidirectionalMap::iterator_right

public
 
 
typedef const_iterator_right iterator_right

normal iterator only declared for convenience, they are also const because otherwise it would be possible to change only one of the internal maps

Defined in Util/BidirectionalMap.h:130


function
Util::BidirectionalMap::BidirectionalMap

public inline
   
   
BidirectionalMap( )

ctor, constructs an empty map

Defined in Util/BidirectionalMap.h:135


function
Util::BidirectionalMap::BidirectionalMap

public inline
     
     
BidirectionalMap( const BidirectionalMap & other )

copy ctor

Parameters

other
the map to be copied

Defined in Util/BidirectionalMap.h:142


function
Util::BidirectionalMap::~BidirectionalMap

public inline
   
   
~BidirectionalMap( )

dtor

Defined in Util/BidirectionalMap.h:147


function
Util::BidirectionalMap::operator=

public inline
     
     
BidirectionalMap & operator=( const BidirectionalMap & other )

assignment operator, assigns the content of other map to this map

Defined in Util/BidirectionalMap.h:151


function
Util::BidirectionalMap::beginLeft

public const inline
   
   
const_iterator_left beginLeft( ) const

Returns

an iterator to the beginning of the left to right map

Defined in Util/BidirectionalMap.h:158


function
Util::BidirectionalMap::beginRight

public const inline
   
   
const_iterator_right beginRight( ) const

Returns

an iterator to the beginning of the right to left map

Defined in Util/BidirectionalMap.h:163


function
Util::BidirectionalMap::clear

public inline
   
   
void clear( )

removes all enties from the map

Defined in Util/BidirectionalMap.h:168


function
Util::BidirectionalMap::empty

public const inline
   
   
bool empty( ) const

Returns

true iff the map is empty

Defined in Util/BidirectionalMap.h:175


function
Util::BidirectionalMap::endLeft

public const inline
   
   
const_iterator_left endLeft( ) const

Returns

an iterator to the end of the left to right map

Defined in Util/BidirectionalMap.h:180


function
Util::BidirectionalMap::endRight

public const inline
   
   
const_iterator_right endRight( ) const

Returns

an iterator to the end of the right to left map

Defined in Util/BidirectionalMap.h:185


function
Util::BidirectionalMap::eraseLeft

public inline
     
     
const_iterator_left eraseLeft( const const_iterator_left & _left )

Parameters

_left
an iterator of the left to right map that points to the value to be deleted

Returns

an iterator to the value following to _left

Defined in Util/BidirectionalMap.h:193


function
Util::BidirectionalMap::eraseRight

public inline
     
     
const_iterator_right eraseRight( const const_iterator_right & _right )

Parameters

_right
an iterator of the right to left map that points to the value to be deleted

Returns

an iterator to the value following to _right

Defined in Util/BidirectionalMap.h:208


function
Util::BidirectionalMap::eraseLeft

public inline
     
     
size_type eraseLeft( const leftToRight_key_t & _left )

Parameters

_left
a left key to be deleted from the mapping

Returns

one if the key was found in the map, zero otherwise

Defined in Util/BidirectionalMap.h:222


function
Util::BidirectionalMap::eraseRight

public inline
     
     
size_type eraseRight( const rightToLeft_key_t & _right )

Parameters

_right
a right key to be deleted from the mapping

Returns

one if the key was found in the map, zero otherwise

Defined in Util/BidirectionalMap.h:235


function
Util::BidirectionalMap::findLeft

public const inline
     
     
const_iterator_left findLeft( const leftToRight_key_t & _left ) const

searches for a left key in the left to right mapping

Parameters

_left
a left key

Returns

an iterator pointing to the value found in the left to right mapping or to its end if the key does not exist

Defined in Util/BidirectionalMap.h:248


function
Util::BidirectionalMap::findRight

public const inline
     
     
const_iterator_right findRight( const rightToLeft_key_t & _right ) const

searches for a right key in the right to left mapping

Parameters

_left
a right key

Returns

an iterator pointing to the value found in the right to left mapping or to its end if the key does not exist

Defined in Util/BidirectionalMap.h:257


function
Util::BidirectionalMap::insert

public inline
     
     
bool insert( const value_type & x )

delegated to insert(x.first, x.second)

Defined in Util/BidirectionalMap.h:264


function
Util::BidirectionalMap::insert

public inline
     
     
bool insert( const leftToRight_key_t & _left,
  const rightToLeft_key_t & _right
)    

tries to insert a new pair of keys into the map

Parameters

_left
a left key
_right
a right key

Returns

true iff the pair of keys has been inserted into the map

Note: the map is only changed if and only if neither _left exists in left to right mapping nor _right exists in right to left mapping

Note: if you want to insert existing keys, please erase them before inserting

Defined in Util/BidirectionalMap.h:282


function
Util::BidirectionalMap::max_Size

public inline
   
   
size_type max_Size( )

Returns

the maximum number of elements that the BidirectionalUnorderedMap container object can hold.

Defined in Util/BidirectionalMap.h:306


function
Util::BidirectionalMap::size

public const inline
   
   
size_type size( ) const

Returns

the number of elements currently stored in this mapping

Defined in Util/BidirectionalMap.h:313


function
Util::BidirectionalMap::swap

public inline
     
     
void swap( BidirectionalMap & other )

Exchanges the content of the container with the content of other. Sizes may differ.

Parameters

other
another BidirectionalUnorderedMap object containing elements of the same type

Defined in Util/BidirectionalMap.h:321