LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
misc::map< T, N > Class Template Reference

Wrapper around std::map providing syntactic sugar for any mapping of types manipulation. More...

#include <map.hh>

Inheritance diagram for misc::map< T, N >:
Collaboration diagram for misc::map< T, N >:

Public Types

typedef map_type::key_type key_type
 The map's key type.
typedef map_type::mapped_type mapped_type
 The type of object associated with the keys.
typedef map_type::value_type value_type
typedef map_type::key_compare key_compare
 Type of the function object that compares two keys for ordering.
typedef map_type::iterator iterator
 Iterator used to iterate through a map.
typedef map_type::const_iterator const_iterator
 Const iterator used to iterate through a map.

Public Member Functions

virtual mapclone () const
 Return a duplicate of this.
key_compare key_comp () const
 Returns the key_compare object used by the map.
virtual N operator[] (const T &t) const
 Lookup for the value associated to t.
N & operator[] (const T &t)
 Return a reference to the value associated to t.
virtual N operator() (const T &t) const
 Lookup for t, throwing std::range_error if it is not found.
virtual std::list< N > operator() (const std::list< T > &ts) const
virtual std::pair< iterator, bool > insert (const std::pair< const T, N > &x)
 Inserts x into the map.
virtual void insert (const map &other)
 Copy the contents of other to this.
template<class... Args>
std::pair< iterator, bool > emplace (Args &&...args)
 Insert a new element built in-place using args into the map.
virtual bool empty () const
 Is the map empty ?
virtual size_t size () const
 Number of known identifiers.
virtual N take (const T &t)
 Remove and return mapping for t from the map.
virtual void clear ()
 Erase all of the elements.
virtual std::ostream & print (std::ostream &ostr) const
 Description of known mappings.
Constructors and destructor.
 map ()
virtual ~map ()
 Return a duplicate of this.
virtual iterator find (const T &t)
virtual const_iterator find (const T &t) const
virtual iterator xfind (const T &t)
virtual const_iterator xfind (const T &t) const
Iterating.
virtual iterator begin ()
virtual iterator end ()
virtual const_iterator begin () const
virtual const_iterator end () const
virtual iterator lower_bound (const T &k)
virtual const_iterator lower_bound (const T &k) const

Protected Types

typedef std::map< T, N > map_type

Protected Attributes

map_type map_
 Mapping from T to N.

Detailed Description

template<class T, class N>
class misc::map< T, N >

Wrapper around std::map providing syntactic sugar for any mapping of types manipulation.

Member Typedef Documentation

template<class T, class N>
typedef map_type::const_iterator misc::map< T, N >::const_iterator

Const iterator used to iterate through a map.

template<class T, class N>
typedef map_type::iterator misc::map< T, N >::iterator

Iterator used to iterate through a map.

template<class T, class N>
typedef map_type::key_compare misc::map< T, N >::key_compare

Type of the function object that compares two keys for ordering.

template<class T, class N>
typedef map_type::key_type misc::map< T, N >::key_type

The map's key type.

template<class T, class N>
typedef std::map<T, N> misc::map< T, N >::map_type
protected
template<class T, class N>
typedef map_type::mapped_type misc::map< T, N >::mapped_type

The type of object associated with the keys.

template<class T, class N>
typedef map_type::value_type misc::map< T, N >::value_type

The type of object, std::pair<const key_type, data_type>, stored in the map.

Constructor & Destructor Documentation

template<class T , class N >
misc::map< T, N >::map ( )
template<class T , class N >
misc::map< T, N >::~map ( )
virtual

Return a duplicate of this.

Member Function Documentation

template<class T , class N >
map< T, N >::iterator misc::map< T, N >::begin ( )
virtual
template<class T , class N >
map< T, N >::const_iterator misc::map< T, N >::begin ( ) const
virtual
template<class T , class N >
void misc::map< T, N >::clear ( )
virtual

Erase all of the elements.

template<class T , class N >
map< T, N > * misc::map< T, N >::clone ( ) const
virtual

Return a duplicate of this.

Reimplemented in misc::endo_map< T >, and misc::endo_map< Temp >.

template<class T , class N >
template<class... Args>
std::pair< typename map< T, N >::iterator, bool > misc::map< T, N >::emplace ( Args &&...  args)

Insert a new element built in-place using args into the map.

template<class T , class N >
bool misc::map< T, N >::empty ( ) const
virtual

Is the map empty ?

template<class T , class N >
map< T, N >::iterator misc::map< T, N >::end ( )
virtual
template<class T , class N >
map< T, N >::const_iterator misc::map< T, N >::end ( ) const
virtual
template<class T, class N >
map< T, N >::iterator misc::map< T, N >::find ( const T &  t)
virtual

Lookup for t.

Referenced by object::DesugarVisitor::variant_exp().

template<class T, class N >
map< T, N >::const_iterator misc::map< T, N >::find ( const T &  t) const
virtual
template<class T, class N>
std::pair< typename map< T, N >::iterator, bool > misc::map< T, N >::insert ( const std::pair< const T, N > &  x)
virtual

Inserts x into the map.

Referenced by regalloc::RegisterAllocator::operator()().

template<class T, class N>
void misc::map< T, N >::insert ( const map< T, N > &  other)
virtual

Copy the contents of other to this.

References misc::map< T, N >::begin(), and misc::map< T, N >::end().

template<class T , class N >
map< T, N >::key_compare misc::map< T, N >::key_comp ( ) const

Returns the key_compare object used by the map.

template<class T, class N >
map< T, N >::iterator misc::map< T, N >::lower_bound ( const T &  k)
virtual

Finds the first element whose key is not less than k.

template<class T, class N >
map< T, N >::const_iterator misc::map< T, N >::lower_bound ( const T &  k) const
virtual
template<class T, class N >
N misc::map< T, N >::operator() ( const T &  t) const
virtual

Lookup for t, throwing std::range_error if it is not found.

Reimplemented in misc::endo_map< T >, and misc::endo_map< Temp >.

template<class T, class N >
std::list< N > misc::map< T, N >::operator() ( const std::list< T > &  ts) const
virtual

Lookup for a list ts of T's, throwing std::range_error if one or several elements are not found.

template<class T, class N >
N misc::map< T, N >::operator[] ( const T &  t) const
virtual

Lookup for the value associated to t.

template<class T, class N >
N & misc::map< T, N >::operator[] ( const T &  t)

Return a reference to the value associated to t.

This method is not virtual, so that it is not automatically instantiated at the instantiation of misc::map. This way, there won't be errors from the compiler about N not being a model of the concept Default Constructible. This is needed for some instantiations of misc::map, notably the ones that uses a symbol::Symbol as mapped type, which has no default constructor (note that in this case everything will be fine as long as this method is not called – compile errors will occur otherwise).

We might want to provide two flavors of misc::map, one that requires that its second parameter is a model of Default Constructible and that provides an operator[] similar to std::map's; and another one that doesn't.

Reimplemented in misc::endo_map< T >, and misc::endo_map< Temp >.

template<class T , class N >
std::ostream & misc::map< T, N >::print ( std::ostream &  ostr) const
virtual

Description of known mappings.

References misc::iendl().

template<class T , class N >
size_t misc::map< T, N >::size ( ) const
virtual

Number of known identifiers.

template<class T, class N >
N misc::map< T, N >::take ( const T &  t)
virtual

Remove and return mapping for t from the map.

template<class T, class N >
map< T, N >::iterator misc::map< T, N >::xfind ( const T &  t)
virtual

Lookup for t and throw an exception if not available.

References misc::find().

template<class T, class N >
map< T, N >::const_iterator misc::map< T, N >::xfind ( const T &  t) const
virtual

References misc::find().

Member Data Documentation

template<class T, class N>
map_type misc::map< T, N >::map_
protected

Mapping from T to N.


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