ROSE  0.11.96.11
Classes | Public Types | Public Member Functions | List of all members
Sawyer::Container::Map< K, T, Cmp, Alloc > Class Template Reference

Description

template<class K, class T, class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
class Sawyer::Container::Map< K, T, Cmp, Alloc >

Container associating values with keys.

This container is similar to the std::map container in the standard template library, but with these differences in addition to those described in the documentation for the Sawyer::Container name space:

See also, HashMap.

Definition at line 66 of file Sawyer/Map.h.

#include <Map.h>

Inheritance diagram for Sawyer::Container::Map< K, T, Cmp, Alloc >:
Inheritance graph
[legend]

Classes

class  ConstKeyIterator
 Bidirectional iterator over keys. More...
 
class  ConstNodeIterator
 Bidirectional iterator over key/value nodes. More...
 
class  ConstValueIterator
 Bidirectional iterator over values. More...
 
class  Node
 Type for stored nodes. More...
 
class  NodeIterator
 Bidirectional iterator over key/value nodes. More...
 
class  ValueIterator
 Bidirectional iterator over values. More...
 

Public Types

typedef K Key
 Type for keys.
 
typedef T Value
 Type for values associated with each key.
 
typedef Cmp Comparator
 Type of comparator, third template argument.
 
typedef Alloc Allocator
 Type of allocator, fourth template argument.
 

Public Member Functions

 Map ()
 Default constructor. More...
 
 Map (const Comparator &comparator, const Allocator &allocator=Allocator())
 Constructs an empty map. More...
 
 Map (const Map &other)
 Copy constructor.
 
template<class Key2 , class T2 , class Cmp2 , class Alloc2 >
 Map (const Map< Key2, T2, Cmp2, Alloc2 > &other)
 Copy constructor. More...
 
template<class Key2 , class T2 , class Cmp2 , class Alloc2 >
Mapoperator= (const Map< Key2, T2, Cmp2, Alloc2 > &other)
 Make this map be a copy of another map. More...
 
bool isEmpty () const
 Determines whether this container is empty. More...
 
size_t size () const
 Number of nodes, keys, or values in this container. More...
 
Key least () const
 Returns the minimum key. More...
 
Key greatest () const
 Returns the maximum key. More...
 
Interval< Keyhull () const
 Returns the range of keys in this map. More...
 
bool exists (const Key &key) const
 Determine if a key exists. More...
 
Optional< ValuegetOptional (const Key &key) const
 Lookup and return a value or nothing. More...
 
const ValuegetOrDefault (const Key &key) const
 Lookup and return a value or a default. More...
 
Mapinsert (const Key &key, const Value &value)
 Insert or update a key/value pair. More...
 
MapinsertDefault (const Key &key)
 Insert or update a key with a default value. More...
 
ValueinsertMaybe (const Key &key, const Value &value)
 Conditionally insert a new key/value pair. More...
 
ValueinsertMaybeDefault (const Key &key)
 Conditionally insert a new key with default value. More...
 
template<class OtherNodeIterator >
MapinsertMaybeMultiple (const boost::iterator_range< OtherNodeIterator > &range)
 Conditionally insert multiple key/value pairs. More...
 
Mapclear ()
 Remove all nodes. More...
 
Maperase (const Key &key)
 Remove a node with specified key. More...
 
template<class OtherKeyIterator >
MaperaseMultiple (const boost::iterator_range< OtherKeyIterator > &range)
 Remove keys stored in another Map. More...
 
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...
 
NodeIterator find (const Key &key)
 Find a node by key. More...
 
ConstNodeIterator find (const Key &key) const
 Find a node by key. More...
 
NodeIterator lowerBound (const Key &key)
 Find a node close to a key. More...
 
ConstNodeIterator lowerBound (const Key &key) const
 Find a node close to a key. More...
 
NodeIterator upperBound (const Key &key)
 Find a node close to a key. More...
 
ConstNodeIterator upperBound (const Key &key) const
 Find a node close to a key. More...
 
Valueoperator[] (const Key &key)
 Return a reference to an existing value. More...
 
const Valueoperator[] (const Key &key) const
 Return a reference to an existing value. More...
 
Valueget (const Key &key)
 Lookup and return an existing value. More...
 
const Valueget (const Key &key) const
 Lookup and return an existing value. More...
 
ValuegetOrElse (const Key &key, Value &dflt)
 Lookup and return a value or something else. More...
 
const ValuegetOrElse (const Key &key, const Value &dflt) const
 Lookup and return a value or something else. More...
 
template<class OtherNodeIterator >
MapinsertMultiple (const OtherNodeIterator &begin, const OtherNodeIterator &end)
 Insert multiple values. More...
 
template<class OtherNodeIterator >
MapinsertMultiple (const boost::iterator_range< OtherNodeIterator > &range)
 Insert multiple values. More...
 
MaperaseAt (const NodeIterator &iter)
 Remove a node by iterator. More...
 
MaperaseAt (const ConstKeyIterator &iter)
 Remove a node by iterator. More...
 
MaperaseAt (const ValueIterator &iter)
 Remove a node by iterator. More...
 
template<class Iter >
MaperaseAtMultiple (const Iter &begin, const Iter &end)
 Remove multiple nodes by iterator range. More...
 
template<class Iter >
MaperaseAtMultiple (const boost::iterator_range< Iter > &range)
 Remove multiple nodes by iterator range. More...
 

Constructor & Destructor Documentation

◆ Map() [1/3]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Sawyer::Container::Map< K, T, Cmp, Alloc >::Map ( )
inline

Default constructor.

Creates an empty map.

Definition at line 296 of file Sawyer/Map.h.

◆ Map() [2/3]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Sawyer::Container::Map< K, T, Cmp, Alloc >::Map ( const Comparator comparator,
const Allocator allocator = Allocator() 
)
inlineexplicit

Constructs an empty map.

This is like the default constructor, but a comparer and allocator can be specified.

Definition at line 301 of file Sawyer/Map.h.

◆ Map() [3/3]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class Key2 , class T2 , class Cmp2 , class Alloc2 >
Sawyer::Container::Map< K, T, Cmp, Alloc >::Map ( const Map< Key2, T2, Cmp2, Alloc2 > &  other)
inline

Copy constructor.

Initializes the new map with copies of the nodes of the other map. The keys and values must be convertible from the other map to this map.

Definition at line 314 of file Sawyer/Map.h.

Member Function Documentation

◆ operator=()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class Key2 , class T2 , class Cmp2 , class Alloc2 >
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::operator= ( const Map< Key2, T2, Cmp2, Alloc2 > &  other)
inline

Make this map be a copy of another map.

The keys and values of the other map must be convertible to the types used for this map.

Definition at line 325 of file Sawyer/Map.h.

◆ nodes() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
boost::iterator_range<NodeIterator> Sawyer::Container::Map< K, T, Cmp, Alloc >::nodes ( )
inline

◆ nodes() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
boost::iterator_range<ConstNodeIterator> Sawyer::Container::Map< K, T, Cmp, Alloc >::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 347 of file Sawyer/Map.h.

◆ keys() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
boost::iterator_range<ConstKeyIterator> Sawyer::Container::Map< K, T, Cmp, Alloc >::keys ( )
inline

◆ keys() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
boost::iterator_range<ConstKeyIterator> Sawyer::Container::Map< K, T, Cmp, Alloc >::keys ( ) const
inline

Iterators for container keys.

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

Definition at line 360 of file Sawyer/Map.h.

◆ values() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
boost::iterator_range<ValueIterator> Sawyer::Container::Map< K, T, Cmp, Alloc >::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 371 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Algorithm::graphBreakCycles(), and Sawyer::Container::IntervalMap< Interval, int >::values().

Here is the caller graph for this function:

◆ values() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
boost::iterator_range<ConstValueIterator> Sawyer::Container::Map< K, T, Cmp, Alloc >::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 374 of file Sawyer/Map.h.

◆ isEmpty()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
bool Sawyer::Container::Map< K, T, Cmp, Alloc >::isEmpty ( ) const
inline

Determines whether this container is empty.

Returns true if the container is empty, and false if it has at least one node. This method executes in constant time.

Definition at line 388 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::greatest(), Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::hull(), Sawyer::Container::DistinctList< T, Cmp >::isEmpty(), Sawyer::Container::IntervalMap< Interval, int >::isEmpty(), and Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::least().

Here is the caller graph for this function:

◆ size()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
size_t Sawyer::Container::Map< K, T, Cmp, Alloc >::size ( ) const
inline

◆ least()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Key Sawyer::Container::Map< K, T, Cmp, Alloc >::least ( ) const
inline

Returns the minimum key.

The map must not be empty.

Definition at line 400 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::hull().

Here is the caller graph for this function:

◆ greatest()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Key Sawyer::Container::Map< K, T, Cmp, Alloc >::greatest ( ) const
inline

Returns the maximum key.

The map must not be empty.

Definition at line 406 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::hull().

Here is the caller graph for this function:

◆ hull()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Interval<Key> Sawyer::Container::Map< K, T, Cmp, Alloc >::hull ( ) const
inline

Returns the range of keys in this map.

The return value is an interval containing the least and greatest keys, inclusive. If the map is empty then an empty interval is returned.

This method is only defined when the map key type is appropriate for the Interval class template (such as when the keys are an integer type).

Definition at line 420 of file Sawyer/Map.h.

◆ find() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
NodeIterator Sawyer::Container::Map< K, T, Cmp, Alloc >::find ( const Key key)
inline

Find a node by key.

Looks for a node whose key is equal to the specified key and returns an iterator to that node, or the end iterator if no such node exists. Two keys are considered equal if this container's Comparator object returns false reflexively. The method executes logorithmic time based on the number of nodes in the container.

Definition at line 437 of file Sawyer/Map.h.

Referenced by Sawyer::Attribute::Storage< SyncTag >::attributeOrDefault(), Sawyer::Container::DistinctList< T, Cmp >::erase(), Sawyer::Attribute::Storage< SyncTag >::getAttribute(), Sawyer::Attribute::Storage< SyncTag >::optionalAttribute(), Sawyer::Container::DistinctList< T, Cmp >::pushBack(), and Sawyer::Container::DistinctList< T, Cmp >::pushFront().

Here is the caller graph for this function:

◆ find() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
ConstNodeIterator Sawyer::Container::Map< K, T, Cmp, Alloc >::find ( const Key key) const
inline

Find a node by key.

Looks for a node whose key is equal to the specified key and returns an iterator to that node, or the end iterator if no such node exists. Two keys are considered equal if this container's Comparator object returns false reflexively. The method executes logorithmic time based on the number of nodes in the container.

Definition at line 440 of file Sawyer/Map.h.

◆ exists()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
bool Sawyer::Container::Map< K, T, Cmp, Alloc >::exists ( const Key key) const
inline

Determine if a key exists.

Looks for a node whose key is equal to the specified key and returns true if found, or false if no such node exists. Two keys are considered equal if this container's Comparator object returns false reflexively. The method executes in logorithmic time based on the number of nodes in the container.

Definition at line 450 of file Sawyer/Map.h.

Referenced by Sawyer::Attribute::Storage< SyncTag >::attributeExists(), Sawyer::Container::BiMap< S, T >::BiMap(), Sawyer::Container::BiMap< S, T >::erase(), Sawyer::Container::BiMap< S, T >::eraseSource(), Sawyer::Container::BiMap< S, T >::eraseTarget(), Sawyer::Container::DistinctList< T, Cmp >::exists(), Sawyer::Container::DistinctList< T, Cmp >::position(), and Sawyer::Attribute::Storage< SyncTag >::setAttributeMaybe().

Here is the caller graph for this function:

◆ lowerBound() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
NodeIterator Sawyer::Container::Map< K, T, Cmp, Alloc >::lowerBound ( const Key key)
inline

Find a node close to a key.

Finds the first node whose key is equal to or larger than the specified key and returns an iterator to that node. If no such node exists, then the end iterator is returned. The internal Comparator object is used to make the comparison. This method executes in logorithmic time based on the number of nodes in the container.

See also
upperBound

Definition at line 463 of file Sawyer/Map.h.

Referenced by Sawyer::Container::IntervalMap< Interval, int >::lowerBound().

Here is the caller graph for this function:

◆ lowerBound() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
ConstNodeIterator Sawyer::Container::Map< K, T, Cmp, Alloc >::lowerBound ( const Key key) const
inline

Find a node close to a key.

Finds the first node whose key is equal to or larger than the specified key and returns an iterator to that node. If no such node exists, then the end iterator is returned. The internal Comparator object is used to make the comparison. This method executes in logorithmic time based on the number of nodes in the container.

See also
upperBound

Definition at line 466 of file Sawyer/Map.h.

◆ upperBound() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
NodeIterator Sawyer::Container::Map< K, T, Cmp, Alloc >::upperBound ( const Key key)
inline

Find a node close to a key.

Finds the first node whose key is larger than the specified key and returns an iterator to that node. If no such node exists, then the end iterator is returned. The internal Comparator object is used to make the comparison. This method executes in logorithmic time based on the number of nodes in the container.

See also
lowerBound

Definition at line 480 of file Sawyer/Map.h.

Referenced by Sawyer::Container::IntervalMap< Interval, int >::upperBound().

Here is the caller graph for this function:

◆ upperBound() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
ConstNodeIterator Sawyer::Container::Map< K, T, Cmp, Alloc >::upperBound ( const Key key) const
inline

Find a node close to a key.

Finds the first node whose key is larger than the specified key and returns an iterator to that node. If no such node exists, then the end iterator is returned. The internal Comparator object is used to make the comparison. This method executes in logorithmic time based on the number of nodes in the container.

See also
lowerBound

Definition at line 483 of file Sawyer/Map.h.

◆ operator[]() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::operator[] ( const Key key)
inline

Return a reference to an existing value.

Returns a reference to the value at the node with the specified key. Unlike std::map, this container does not instantiate a new key/value pair if the key is not in the map's domain. In other words, the array operator for this class is more like an array operator on arrays or vectors–such objects are not automatically extended if dereferenced with an operand that is outside the domain.

If the key is not part of this map's domain then an std:domain_error is thrown.

See also
insert insertDefault

Definition at line 506 of file Sawyer/Map.h.

◆ operator[]() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
const Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::operator[] ( const Key key) const
inline

Return a reference to an existing value.

Returns a reference to the value at the node with the specified key. Unlike std::map, this container does not instantiate a new key/value pair if the key is not in the map's domain. In other words, the array operator for this class is more like an array operator on arrays or vectors–such objects are not automatically extended if dereferenced with an operand that is outside the domain.

If the key is not part of this map's domain then an std:domain_error is thrown.

See also
insert insertDefault

Definition at line 509 of file Sawyer/Map.h.

◆ get() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::get ( const Key key)
inline

Lookup and return an existing value.

Returns a reference to the value at the node with the specified key, which must exist. If the key is not part of this map's domain then an std:domain_error is thrown.

See also
insert insertDefault

Definition at line 522 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::operator[]().

Here is the caller graph for this function:

◆ get() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
const Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::get ( const Key key) const
inline

Lookup and return an existing value.

Returns a reference to the value at the node with the specified key, which must exist. If the key is not part of this map's domain then an std:domain_error is thrown.

See also
insert insertDefault

Definition at line 528 of file Sawyer/Map.h.

◆ getOptional()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Optional<Value> Sawyer::Container::Map< K, T, Cmp, Alloc >::getOptional ( const Key key) const
inline

Lookup and return a value or nothing.

Looks up the node with the specified key and returns either a copy of its value, or nothing. This method executes in logorithmic time.

Here's an example of one convenient way to use this:

...
if (Optional<FileInfo> fileInfo = files.getOptional(fileName))
std::cout <<"file info for \"" <<fileName <<"\" is " <<*fileInfo <<"\n";

The equivalent STL approach is:

std::map<std::string, FileInfo> files;
...
std::map<std::string, FileInfo>::const_iterator filesIter = files.find(fileName);
if (fileIter != files.end())
std::cout <<"file info for \"" <<fileName <<"\" is " <<filesIter->second <<"\n";

Definition at line 559 of file Sawyer/Map.h.

Referenced by Sawyer::Attribute::Storage< SyncTag >::attributeOrElse(), Sawyer::Attribute::Storage< SyncTag >::getAttribute(), and Sawyer::Container::GraphBimapIndex< VertexOrEdgeKey, VertexOrEdgeConstIterator >::lookup().

Here is the caller graph for this function:

◆ getOrElse() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::getOrElse ( const Key key,
Value dflt 
)
inline

Lookup and return a value or something else.

This is similar to the get method, except a default can be provided. If a node with the specified key is present in this container, then a reference to that node's value is returned, otherwise the (reference to) supplied default is returned.

Definition at line 571 of file Sawyer/Map.h.

◆ getOrElse() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
const Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::getOrElse ( const Key key,
const Value dflt 
) const
inline

Lookup and return a value or something else.

This is similar to the get method, except a default can be provided. If a node with the specified key is present in this container, then a reference to that node's value is returned, otherwise the (reference to) supplied default is returned.

Definition at line 575 of file Sawyer/Map.h.

◆ getOrDefault()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
const Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::getOrDefault ( const Key key) const
inline

Lookup and return a value or a default.

This is similar to the getOrElse method except when the key is not present in the map, a reference to a const, default-constructed value is returned.

Definition at line 586 of file Sawyer/Map.h.

Referenced by Sawyer::CommandLine::ParserResult::have().

Here is the caller graph for this function:

◆ insert()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::insert ( const Key key,
const Value value 
)
inline

◆ insertDefault()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::insertDefault ( const Key key)
inline

Insert or update a key with a default value.

The value associated with key in the map is replaced with a default-constructed value. If the key does not exist then it is inserted with a default value. This operation is similar to the array operator of std::map.

See also
insert insertMaybe insertMaybeDefault insertMultiple insertMaybeMultiple

Definition at line 616 of file Sawyer/Map.h.

◆ insertMultiple() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class OtherNodeIterator >
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMultiple ( const OtherNodeIterator &  begin,
const OtherNodeIterator &  end 
)
inline

Insert multiple values.

Inserts copies of the nodes in the specified node iterator range. The iterators must iterate over objects that have key and value methods that return keys and values that are convertible to the types used by this container.

The normal way to insert the contents of one map into another is:

Map<...> source = ...;
Map<...> destination = ...;
destination.insertMultiple(source.nodes());
See also
insert insertDefault insertMaybe insertMaybeDefault insertMaybeMultiple

Definition at line 639 of file Sawyer/Map.h.

Referenced by Sawyer::Container::IntervalMap< Interval, int >::erase(), and Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::insertMultiple().

Here is the caller graph for this function:

◆ insertMultiple() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class OtherNodeIterator >
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMultiple ( const boost::iterator_range< OtherNodeIterator > &  range)
inline

Insert multiple values.

Inserts copies of the nodes in the specified node iterator range. The iterators must iterate over objects that have key and value methods that return keys and values that are convertible to the types used by this container.

The normal way to insert the contents of one map into another is:

Map<...> source = ...;
Map<...> destination = ...;
destination.insertMultiple(source.nodes());
See also
insert insertDefault insertMaybe insertMaybeDefault insertMaybeMultiple

Definition at line 645 of file Sawyer/Map.h.

◆ insertMaybe()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybe ( const Key key,
const Value value 
)
inline

Conditionally insert a new key/value pair.

Inserts the key/value pair into the container if the container does not yet have a node with the same key. This method executes in logarithmic time. The return value is a reference to the value that is in the container, either the value that previously existed or a copy of the specified value.

See also
insert insertDefault insertMaybeDefault insertMultiple insertMaybeMultiple

Definition at line 657 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< VertexOrEdgeKey, VertexOrEdgeConstIterator >::insertMaybeMultiple().

Here is the caller graph for this function:

◆ insertMaybeDefault()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Value& Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybeDefault ( const Key key)
inline

Conditionally insert a new key with default value.

Inserts a key/value pair into the container if the container does not yet have a node with the same key. The value is default-constructed. This method executes in logarithmic time. The return value is a reference to the value that is in the container, either the value that previously existed or the new default-constructed value.

See also
insert insertDefault insertMultiple insertMaybeMultiple

Definition at line 668 of file Sawyer/Map.h.

Referenced by Sawyer::MultiInstanceTls< T >::get(), and Sawyer::MultiInstanceTls< T >::operator T().

Here is the caller graph for this function:

◆ insertMaybeMultiple()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class OtherNodeIterator >
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybeMultiple ( const boost::iterator_range< OtherNodeIterator > &  range)
inline

Conditionally insert multiple key/value pairs.

Inserts each of the specified key/value pairs into this container where this container does not already contain a value for the key. The return value is a reference to the container itself so that this method can be chained with others.

See also
insert insertDefault insertMaybe insertMaybeDefault insertMultiple

Definition at line 679 of file Sawyer/Map.h.

◆ clear()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::clear ( )
inline

◆ erase()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::erase ( const Key key)
inline

◆ eraseMultiple()

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class OtherKeyIterator >
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::eraseMultiple ( const boost::iterator_range< OtherKeyIterator > &  range)
inline

Remove keys stored in another Map.

All nodes of this container whose keys are equal to any key in the other container are removed from this container. The keys of the other container must be convertible to the types used by this container, and two keys are considered equal if this container's Comparator object returns false reflexively. The method executes in N log(N+M) time.

See also
erase eraseAt eraseAtMultiple

Definition at line 715 of file Sawyer/Map.h.

◆ eraseAt() [1/3]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::eraseAt ( const NodeIterator iter)
inline

Remove a node by iterator.

Removes the node referenced by iter. The iterator must reference a valid node in this container.

See also
erase eraseMultiple eraseAtMultiple

Definition at line 728 of file Sawyer/Map.h.

Referenced by Sawyer::Container::DistinctList< T, Cmp >::erase(), and Sawyer::Container::IntervalMap< Interval, int >::insert().

Here is the caller graph for this function:

◆ eraseAt() [2/3]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::eraseAt ( const ConstKeyIterator iter)
inline

Remove a node by iterator.

Removes the node referenced by iter. The iterator must reference a valid node in this container.

See also
erase eraseMultiple eraseAtMultiple

Definition at line 732 of file Sawyer/Map.h.

◆ eraseAt() [3/3]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::eraseAt ( const ValueIterator iter)
inline

Remove a node by iterator.

Removes the node referenced by iter. The iterator must reference a valid node in this container.

See also
erase eraseMultiple eraseAtMultiple

Definition at line 740 of file Sawyer/Map.h.

◆ eraseAtMultiple() [1/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class Iter >
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::eraseAtMultiple ( const Iter &  begin,
const Iter &  end 
)
inline

Remove multiple nodes by iterator range.

The iterator range must contain iterators that point into this container.

See also
erase eraseAt eraseMultiple

Definition at line 754 of file Sawyer/Map.h.

Referenced by Sawyer::Container::IntervalMap< Interval, int >::erase().

Here is the caller graph for this function:

◆ eraseAtMultiple() [2/2]

template<class K , class T , class Cmp = std::less<K>, class Alloc = std::allocator<std::pair<const K, T> >>
template<class Iter >
Map& Sawyer::Container::Map< K, T, Cmp, Alloc >::eraseAtMultiple ( const boost::iterator_range< Iter > &  range)
inline

Remove multiple nodes by iterator range.

The iterator range must contain iterators that point into this container.

See also
erase eraseAt eraseMultiple

Definition at line 759 of file Sawyer/Map.h.


The documentation for this class was generated from the following file:
Rose::Diagnostics::destination
ROSE_DLL_API Sawyer::Message::DestinationPtr destination
Default destination for ROSE diagnostics.
Map
Extends std::map with methods that return optional values.
Definition: Map.h:10