ROSE  0.11.145.0
Classes | Public Types | Public Member Functions | List of all members
Sawyer::Container::GraphIteratorMap< K, V > Class Template Reference

Description

template<class K, class V>
class Sawyer::Container::GraphIteratorMap< K, V >

Map of graph edge or vertex pointers to some other value.

This container maps edge or vertex pointers (iterators) to values of some other type, T. Iterators form a total order by comparing their ID numbers, which is why all iterators in this container must belong to the same graph. This container is able to store only valid iterators, not end iterators. Attempting to insert an iterator with the same ID number as one that already exists is a no-op.

Since ID numbers are not stable over erasure, this container must be notified whenever edges or vertices (whichever are stored by this container), are removed from the graph, even if the items removed from the graph are not the same ones as what are stored in this container.

Definition at line 29 of file GraphIteratorMap.h.

#include <util/Sawyer/GraphIteratorMap.h>

Inheritance diagram for Sawyer::Container::GraphIteratorMap< K, V >:
Inheritance graph
[legend]

Classes

class  ConstKeyIterator
 Bidirectional iterator over keys. More...
 
class  ConstNodeIterator
 Bidirectional iterator over constant key/value nodes. More...
 
class  ConstValueIterator
 Bidirectional iterator over values. More...
 
class  Node
 The data stored at each node of the map. More...
 
class  NodeIterator
 Bidirectional iterator over key/value nodes. More...
 
class  ValueIterator
 Bidirectional iterator over values. More...
 

Public Types

typedef K Key
 Graph edge or vertex iterator used as keys. More...
 
typedef V Value
 Type of value associated with each key. More...
 
typedef StlVector::value_type value_type
 
typedef StlVector::allocator_type allocator_type
 
typedef StlVector::reference reference
 
typedef StlVector::pointer pointer
 
typedef StlVector::const_pointer const_pointer
 
typedef StlVector::iterator iterator
 
typedef StlVector::const_iterator const_iterator
 
typedef StlVector::reverse_iterator reverse_iterator
 
typedef StlVector::const_reverse_iterator const_reverse_iterator
 
typedef StlVector::difference_type difference_type
 
typedef StlVector::size_type size_type
 

Public Member Functions

 GraphIteratorMap ()
 Default construct an empty map. More...
 
void updateIdNumbers ()
 Indicate that an update is necessary due to erasures. More...
 
void insert (const Key &item, const Value &value)
 Insert the specified edge or vertex associated with a value. More...
 
ValueinsertMaybe (const Key &item, const Value &value)
 Insert a value only if its key doesn't already exist. More...
 
ValueinsertMaybeDefault (const Key &item)
 Insert a default value if its key doesn't already exist. More...
 
void erase (const Key &item)
 Erase the specified key if it exists. More...
 
void clear ()
 Remove all entries from this container. More...
 
bool exists (const Key &item) const
 Does the key exist in the map?
 
Sawyer::Optional< Valuefind (const Key &item) const
 Find the value associated with a particular key. More...
 
Value operator[] (const Key &item) const
 Return the value associated with an existing key. More...
 
NodeIterator begin ()
 
ConstNodeIterator begin () const
 
NodeIterator end ()
 
ConstNodeIterator end () const
 
boost::iterator_range< NodeIteratornodes ()
 Iterators for container nodes. More...
 
boost::iterator_range< ConstNodeIteratornodes () const
 Iterators for container nodes. More...
 
boost::iterator_range< ConstKeyIteratorkeys ()
 Iterators for container keys. More...
 
boost::iterator_range< ConstKeyIteratorkeys () const
 Iterators for container keys. More...
 
boost::iterator_range< ValueIteratorvalues ()
 Iterators for container values. More...
 
boost::iterator_range< ConstValueIteratorvalues () const
 Iterators for container values. More...
 

Member Typedef Documentation

template<class K, class V>
typedef K Sawyer::Container::GraphIteratorMap< K, V >::Key

Graph edge or vertex iterator used as keys.

Definition at line 31 of file GraphIteratorMap.h.

template<class K, class V>
typedef V Sawyer::Container::GraphIteratorMap< K, V >::Value

Type of value associated with each key.

Definition at line 32 of file GraphIteratorMap.h.

Constructor & Destructor Documentation

template<class K, class V>
Sawyer::Container::GraphIteratorMap< K, V >::GraphIteratorMap ( )
inline

Default construct an empty map.

Definition at line 318 of file GraphIteratorMap.h.

Member Function Documentation

template<class K, class V>
void Sawyer::Container::GraphIteratorMap< K, V >::updateIdNumbers ( )
inline

Indicate that an update is necessary due to erasures.

If the graph whose iterators are stored in this container has any edges or vertices that are erased (whichever type are stored in this container), then this function should be called to tell the container that the ID numbers of its contained iterators have possibly changed.

The actual re-sorting of this container will be delayed as long as possible, but logically the user can assume that it occurs immediately.

Definition at line 333 of file GraphIteratorMap.h.

Referenced by Sawyer::Container::GraphIteratorBiMap< ControlFlowGraph::ConstVertexIterator, ControlFlowGraph::ConstVertexIterator >::updateIdNumbers().

template<class K, class V>
void Sawyer::Container::GraphIteratorMap< K, V >::insert ( const Key item,
const Value value 
)
inline

Insert the specified edge or vertex associated with a value.

If the edge or vertex already exists, then its value is changed, otherwise a new edge or vertex with the associated value is inserted into the map. Note that this is different behavior than std::map where no new value is inserted if the key already exists.

Definition at line 342 of file GraphIteratorMap.h.

Referenced by Sawyer::Container::GraphIteratorBiMap< ControlFlowGraph::ConstVertexIterator, ControlFlowGraph::ConstVertexIterator >::insert().

template<class K, class V>
Value& Sawyer::Container::GraphIteratorMap< K, V >::insertMaybe ( const Key item,
const Value value 
)
inline

Insert a value only if its key doesn't already exist.

Returns a reference to the value, which should be used immediately. The reference is valid until the next modifying operation on this object.

Definition at line 357 of file GraphIteratorMap.h.

Referenced by Sawyer::Container::GraphIteratorMap< LhsIterator, RhsIterator >::insertMaybeDefault().

template<class K, class V>
Value& Sawyer::Container::GraphIteratorMap< K, V >::insertMaybeDefault ( const Key item)
inline

Insert a default value if its key doesn't already exist.

Returns a reference to the value, which should be used immediately. The reference is value until the next modifying operation on this object.

Definition at line 370 of file GraphIteratorMap.h.

template<class K, class V>
void Sawyer::Container::GraphIteratorMap< K, V >::erase ( const Key item)
inline
template<class K, class V>
void Sawyer::Container::GraphIteratorMap< K, V >::clear ( )
inline
template<class K, class V>
Sawyer::Optional<Value> Sawyer::Container::GraphIteratorMap< K, V >::find ( const Key item) const
inline
template<class K, class V>
Value Sawyer::Container::GraphIteratorMap< K, V >::operator[] ( const Key item) const
inline

Return the value associated with an existing key.

Definition at line 414 of file GraphIteratorMap.h.

template<class K, class V>
boost::iterator_range<NodeIterator> Sawyer::Container::GraphIteratorMap< K, V >::nodes ( )
inline

Iterators for container nodes.

This returns a range of node-iterators that will traverse all nodes (key/value pairs) of this container.

Definition at line 428 of file GraphIteratorMap.h.

Referenced by Sawyer::Container::GraphIteratorBiMap< ControlFlowGraph::ConstVertexIterator, ControlFlowGraph::ConstVertexIterator >::GraphIteratorBiMap().

template<class K, class V>
boost::iterator_range<ConstNodeIterator> Sawyer::Container::GraphIteratorMap< K, V >::nodes ( ) const
inline

Iterators for container nodes.

This returns a range of node-iterators that will traverse all nodes (key/value pairs) of this container.

Definition at line 432 of file GraphIteratorMap.h.

template<class K, class V>
boost::iterator_range<ConstKeyIterator> Sawyer::Container::GraphIteratorMap< K, V >::keys ( )
inline

Iterators for container keys.

Returns a range of key-iterators that will traverse the keys of this container.

Definition at line 443 of file GraphIteratorMap.h.

template<class K, class V>
boost::iterator_range<ConstKeyIterator> Sawyer::Container::GraphIteratorMap< K, V >::keys ( ) const
inline

Iterators for container keys.

Returns a range of key-iterators that will traverse the keys of this container.

Definition at line 447 of file GraphIteratorMap.h.

template<class K, class V>
boost::iterator_range<ValueIterator> Sawyer::Container::GraphIteratorMap< K, V >::values ( )
inline

Iterators for container values.

Returns a range of iterators that will traverse the user-defined values of this container. The values are iterated in key order, although the keys are not directly available via these iterators.

Definition at line 459 of file GraphIteratorMap.h.

template<class K, class V>
boost::iterator_range<ConstValueIterator> Sawyer::Container::GraphIteratorMap< K, V >::values ( ) const
inline

Iterators for container values.

Returns a range of iterators that will traverse the user-defined values of this container. The values are iterated in key order, although the keys are not directly available via these iterators.

Definition at line 463 of file GraphIteratorMap.h.


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