OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
BiMap< Left, Right > Class Template Reference

Simple bidirectional map with lookup in both directions. More...

#include <BiMap.h>

Collaboration diagram for BiMap< Left, Right >:
Collaboration graph

Classes

struct  left_view
 Left-map view with find/at helpers. More...
 
struct  relation
 Pair relation used for initialization. More...
 
struct  right_view
 Right-map view with find/at helpers. More...
 

Public Types

using left_map = std::map< Left, Right >
 
using right_map = std::map< Right, Left >
 

Public Member Functions

 BiMap ()
 Construct an empty bimap.
 
void insert (const Left &left, const Right &right)
 Insert or overwrite a left/right association.
 
left_map::iterator left_find (const Left &key)
 Find an entry by left key.
 
right_map::iterator right_find (const Right &key)
 Find an entry by right key.
 
left_map::iterator left_end ()
 End iterator for left map.
 
right_map::iterator right_end ()
 End iterator for right map.
 
const Right & left_at (const Left &key) const
 Get mapped right value by left key (throws if missing).
 
const Left & right_at (const Right &key) const
 Get mapped left value by right key (throws if missing).
 

Public Attributes

left_view left
 Left view accessor.
 
right_view right
 Right view accessor.
 

Private Attributes

left_map left_map_
 
right_map right_map_
 

Detailed Description

template<typename Left, typename Right>
class BiMap< Left, Right >

Simple bidirectional map with lookup in both directions.

Template Parameters
LeftKey type for the left map.
RightKey type for the right map.

Definition at line 28 of file BiMap.h.

Member Typedef Documentation

◆ left_map

template<typename Left , typename Right >
using BiMap< Left, Right >::left_map = std::map<Left, Right>

Definition at line 30 of file BiMap.h.

◆ right_map

template<typename Left , typename Right >
using BiMap< Left, Right >::right_map = std::map<Right, Left>

Definition at line 31 of file BiMap.h.

Constructor & Destructor Documentation

◆ BiMap()

template<typename Left , typename Right >
BiMap< Left, Right >::BiMap ( )
inline

Construct an empty bimap.

Definition at line 89 of file BiMap.h.

Member Function Documentation

◆ insert()

template<typename Left , typename Right >
void BiMap< Left, Right >::insert ( const Left &  left,
const Right &  right 
)
inline

Insert or overwrite a left/right association.

Parameters
leftInput: left key.
rightInput: right key.

Definition at line 99 of file BiMap.h.

References BiMap< Left, Right >::left, BiMap< Left, Right >::left_map_, BiMap< Left, Right >::right, and BiMap< Left, Right >::right_map_.

Referenced by make_bimap(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ left_at()

template<typename Left , typename Right >
const Right & BiMap< Left, Right >::left_at ( const Left &  key) const
inline

Get mapped right value by left key (throws if missing).

Parameters
keyInput: left key.
Returns
Output: mapped right value.

Definition at line 124 of file BiMap.h.

References BiMap< Left, Right >::left_map_.

Referenced by TEST_F(), TEST_F(), and TEST_F().

◆ left_end()

template<typename Left , typename Right >
left_map::iterator BiMap< Left, Right >::left_end ( )
inline

End iterator for left map.

Returns
Output: end iterator.

Definition at line 116 of file BiMap.h.

References BiMap< Left, Right >::left_map_.

Referenced by TEST_F().

◆ left_find()

template<typename Left , typename Right >
left_map::iterator BiMap< Left, Right >::left_find ( const Left &  key)
inline

Find an entry by left key.

Parameters
keyInput: left key.
Returns
Output: iterator to entry or end().

Definition at line 107 of file BiMap.h.

References BiMap< Left, Right >::left_map_.

Referenced by TEST_F().

◆ right_at()

template<typename Left , typename Right >
const Left & BiMap< Left, Right >::right_at ( const Right &  key) const
inline

Get mapped left value by right key (throws if missing).

Parameters
keyInput: right key.
Returns
Output: mapped left value.

Definition at line 135 of file BiMap.h.

References BiMap< Left, Right >::right_map_.

Referenced by TEST_F(), TEST_F(), and TEST_F().

◆ right_end()

template<typename Left , typename Right >
right_map::iterator BiMap< Left, Right >::right_end ( )
inline

End iterator for right map.

Returns
Output: end iterator.

Definition at line 119 of file BiMap.h.

References BiMap< Left, Right >::right_map_.

Referenced by TEST_F().

◆ right_find()

template<typename Left , typename Right >
right_map::iterator BiMap< Left, Right >::right_find ( const Right &  key)
inline

Find an entry by right key.

Parameters
keyInput: right key.
Returns
Output: iterator to entry or end().

Definition at line 112 of file BiMap.h.

References BiMap< Left, Right >::right_map_.

Referenced by TEST_F().

Member Data Documentation

◆ left

template<typename Left , typename Right >
left_view BiMap< Left, Right >::left

◆ left_map_

template<typename Left , typename Right >
left_map BiMap< Left, Right >::left_map_
private

◆ right

template<typename Left , typename Right >
right_view BiMap< Left, Right >::right

◆ right_map_

template<typename Left , typename Right >
right_map BiMap< Left, Right >::right_map_
private

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