classias::quark2_base< item0_base, item1_base > Class Template Reference


Detailed Description

template<class item0_base, class item1_base>
class classias::quark2_base< item0_base, item1_base >

Quark for associating a pair of items with an identifier.

Parameters:
item0_base The type of an item #0.
item1_base The type of an item #1.


Public Types

typedef item0_base item0_type
 The type representing an item #0.
typedef item1_base item1_type
 The type representing an item #1.
typedef std::pair< item0_type,
item1_type
elem_type
 The type representing a pair of items.
typedef std::vector< elem_typeinverse_map_type
 The type implementing a vector of pairs of items.
typedef inverse_map_type::size_type value_type
 The type representing a unique identifier.
typedef UNORDERED_MAP< elem_type,
value_type
forward_map_type
 The type associating a pair of items to its unique identifier.

Public Member Functions

 quark2_base ()
 Constructs the object.
virtual ~quark2_base ()
 Destructs the object.
value_type size () const
 Returns the number of item-identifier associations.
bool exists (const item0_type &x, const item1_base &y) const
 Tests whether a pair of items has an identifier assigned.
value_type operator() (const item0_type &x, const item1_base &y)
 Assigns the unique identifier for a pair of items.
value_type associate (const item0_type &x, const item1_base &y)
 Assigns the unique identifier for a pair of items.
value_type to_value (const item0_type &x, const item1_type &y) const
 Returns the unique identifier for a pair of items.
value_type to_value (const item0_type &x, const item1_type &y, const value_type &def) const
 Returns the unique identifier for a pair of items.
void to_item (const value_type &v, item0_type &x, item1_base &y) const
 Returns the pair for the unique identifier.

Protected Attributes

forward_map_type m_fwd
 Forward mapping: (item0, item1) -> value.
inverse_map_type m_inv
 Inverse mapping: value -> (item0, item1).


Member Function Documentation

template<class item0_base, class item1_base>
value_type classias::quark2_base< item0_base, item1_base >::size (  )  const [inline]

Returns the number of item-identifier associations.

Return values:
value_type The number of associations between items and identifiers.

template<class item0_base, class item1_base>
bool classias::quark2_base< item0_base, item1_base >::exists ( const item0_type x,
const item1_base &  y 
) const [inline]

Tests whether a pair of items has an identifier assigned.

Parameters:
x The item #0.
y The item #1.
Return values:
bool true if the pair of items is known.

template<class item0_base, class item1_base>
value_type classias::quark2_base< item0_base, item1_base >::operator() ( const item0_type x,
const item1_base &  y 
) [inline]

Assigns the unique identifier for a pair of items.

If the pair is unknown, this function assigns a new unique identifier to the pair and return it. If the item is known, this function returns the existing identifier that was associated with the item.

Parameters:
x The item #0.
y The item #1.
Returns:
value_type The unique identifier.

template<class item0_base, class item1_base>
value_type classias::quark2_base< item0_base, item1_base >::associate ( const item0_type x,
const item1_base &  y 
) [inline]

Assigns the unique identifier for a pair of items.

If the pair is unknown, this function assigns a new unique identifier to the pair and return it. If the item is known, this function returns the existing identifier that was associated with the item.

Parameters:
x The item #0.
y The item #1.
Returns:
value_type The unique identifier.

template<class item0_base, class item1_base>
value_type classias::quark2_base< item0_base, item1_base >::to_value ( const item0_type x,
const item1_type y 
) const [inline]

Returns the unique identifier for a pair of items.

If the pair is unknown, this function throws quark_error.

Parameters:
x The item #0.
y The item #1.
Returns:
value_type The unique identifier.
Exceptions:
quark_error. 

template<class item0_base, class item1_base>
value_type classias::quark2_base< item0_base, item1_base >::to_value ( const item0_type x,
const item1_type y,
const value_type def 
) const [inline]

Returns the unique identifier for a pair of items.

If the pair is unknown, this function returns the default identifier.

Parameters:
x The item #0.
y The item #1.
def The default identifier if the pair is unknown.
Returns:
value_type The unique identifier.

template<class item0_base, class item1_base>
void classias::quark2_base< item0_base, item1_base >::to_item ( const value_type v,
item0_type x,
item1_base &  y 
) const [inline]

Returns the pair for the unique identifier.

If the unique identifier is unknown, this function throws quark_error.

Parameters:
v The unique identifier.
x The reference to item #0.
y The reference to item #1.
Exceptions:
quark_error. 


Copyright (c) 2002-2009 by Naoaki Okazaki
Mon Dec 28 23:41:06 2009