ROSE  0.9.10.103
Public Types | Public Member Functions | List of all members
Sawyer::Container::BiMap< S, T > Class Template Reference

Description

template<class S, class T>
class Sawyer::Container::BiMap< S, T >

One-to-one mapping between source and target values.

This container holds a one-to-one mapping from values in a domain to values in a range and can look up values in the forward or reverse direction in log time. It does so by consistently maintaining two maps: a forward map and a reverse map. The forward map maps values in the domain to values in the range, while the reverse map goes the other direction. The forward and reverse methods return const references to these maps. The BiMap container provides methods for modifying the mapping.

Definition at line 26 of file BiMap.h.

#include <BiMap.h>

Inheritance diagram for Sawyer::Container::BiMap< S, T >:
Inheritance graph
[legend]

Public Types

typedef S Source
 Type of values in the domain. More...
 
typedef T Target
 Type of values in the range. More...
 
typedef Sawyer::Container::Map< Source, TargetForward
 Type for domain-to-range map. More...
 
typedef Sawyer::Container::Map< Target, SourceReverse
 Type for range-to-domain map. More...
 

Public Member Functions

 BiMap ()
 Default constructor. More...
 
 BiMap (const BiMap &other)
 Copy constructor. More...
 
template<class U >
 BiMap (const BiMap< Source, U > &a, const BiMap< U, Target > &b)
 Construct a new map by composition of two maps. More...
 
void clear ()
 Erase all mappings. More...
 
bool eraseSource (const Source &source)
 Erase domain value and its associated range value. More...
 
bool eraseTarget (const Target &target)
 Erase range value and its associated domain value. More...
 
bool erase (const Source &source, const Target &target)
 Erase a specific map entry. More...
 
void insert (const Source &source, const Target &target)
 Insert a new mapping. More...
 
const Forwardforward () const
 Return forward mapping. More...
 
const Reversereverse () const
 Return reverse mapping. More...
 

Member Typedef Documentation

template<class S, class T>
typedef S Sawyer::Container::BiMap< S, T >::Source

Type of values in the domain.

Definition at line 28 of file BiMap.h.

template<class S, class T>
typedef T Sawyer::Container::BiMap< S, T >::Target

Type of values in the range.

Definition at line 29 of file BiMap.h.

template<class S, class T>
typedef Sawyer::Container::Map<Source, Target> Sawyer::Container::BiMap< S, T >::Forward

Type for domain-to-range map.

Definition at line 30 of file BiMap.h.

template<class S, class T>
typedef Sawyer::Container::Map<Target, Source> Sawyer::Container::BiMap< S, T >::Reverse

Type for range-to-domain map.

Definition at line 31 of file BiMap.h.

Constructor & Destructor Documentation

template<class S, class T>
Sawyer::Container::BiMap< S, T >::BiMap ( )
inline

Default constructor.

Constructs an empty mapping.

Definition at line 39 of file BiMap.h.

template<class S, class T>
Sawyer::Container::BiMap< S, T >::BiMap ( const BiMap< S, T > &  other)

Copy constructor.

template<class S, class T>
template<class U >
Sawyer::Container::BiMap< S, T >::BiMap ( const BiMap< Source, U > &  a,
const BiMap< U, Target > &  b 
)
inline

Construct a new map by composition of two maps.

Given two BiMap objects where the range type of the first is the domain type of the second, construct a new BiMap from the domain of the first to the range of the second. The new map will contain only those domain/range pairs that map across both input maps.

Definition at line 50 of file BiMap.h.

Member Function Documentation

template<class S, class T>
void Sawyer::Container::BiMap< S, T >::clear ( )
inline

Erase all mappings.

This results in a map whose state is the same as a default-constructed BiMap.

Definition at line 63 of file BiMap.h.

Referenced by Rose::BinaryAnalysis::FeasiblePath::reset().

template<class S, class T>
bool Sawyer::Container::BiMap< S, T >::eraseSource ( const Source source)
inline

Erase domain value and its associated range value.

If source exists in this map's domain, then it is removed along with the corresponding value in the range. Otherwise the map is not modified. Returns true if the map was modified, false if not.

Definition at line 72 of file BiMap.h.

Referenced by Sawyer::Container::BiMap< Rose::BinaryAnalysis::Concolic::Database::TestSuiteId, Rose::BinaryAnalysis::Concolic::TestSuite::SharedPointer< Database > >::insert().

template<class S, class T>
bool Sawyer::Container::BiMap< S, T >::eraseTarget ( const Target target)
inline

Erase range value and its associated domain value.

If target exists in this map's range, then it is removed along with the corresponding value in the domain. Otherwise the map is not modified. Returns true if the map was modified, false if not.

Definition at line 84 of file BiMap.h.

Referenced by Sawyer::Container::BiMap< Rose::BinaryAnalysis::Concolic::Database::TestSuiteId, Rose::BinaryAnalysis::Concolic::TestSuite::SharedPointer< Database > >::insert().

template<class S, class T>
bool Sawyer::Container::BiMap< S, T >::erase ( const Source source,
const Target target 
)
inline

Erase a specific map entry.

Erases the 1:1 mapping between source and target if present. This is a no-op unless source is a member of the domain and target is a member of the range and source maps to target (and vice versa). Returns true if the map was modified, false if not.

Definition at line 97 of file BiMap.h.

template<class S, class T>
void Sawyer::Container::BiMap< S, T >::insert ( const Source source,
const Target target 
)
inline

Insert a new mapping.

Creates a new mapping from source in the domain to target in the range. If source is already a member of the domain then it is first erased along with its corresponding value in the range; likewise, if target is already a member of the range then it is first erased along with its corresponding value in the domain.

Definition at line 110 of file BiMap.h.

template<class S, class T>
const Forward& Sawyer::Container::BiMap< S, T >::forward ( ) const
inline

Return forward mapping.

The keys of the forward map are values in the domain, and its values are in the range.

Definition at line 120 of file BiMap.h.

template<class S, class T>
const Reverse& Sawyer::Container::BiMap< S, T >::reverse ( ) const
inline

Return reverse mapping.

The keys of the reverse map are values in the range, and its values are in the domain.

Definition at line 127 of file BiMap.h.


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