ROSE 0.11.145.192
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 72 of file Sawyer/Map.h.

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

Member Typedef Documentation

◆ Key

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

Type for keys.

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

◆ Value

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

Type for values associated with each key.

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

◆ Comparator

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

Type of comparator, third template argument.

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

◆ Allocator

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

Type of allocator, fourth template argument.

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

Constructor & Destructor Documentation

◆ Map() [1/4]

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 332 of file Sawyer/Map.h.

◆ Map() [2/4]

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 337 of file Sawyer/Map.h.

◆ Map() [3/4]

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 Map< K, T, Cmp, Alloc > &  other)
inline

Copy constructor.

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

◆ Map() [4/4]

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 350 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::nodes().

Member Function Documentation

◆ operator=() [1/2]

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 >::operator= ( const Map< K, T, Cmp, Alloc > &  other)
inline

Definition at line 357 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> >>
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 368 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::clear(), and Sawyer::Container::Map< K, T, Cmp, Alloc >::nodes().

◆ 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 390 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 403 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 414 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Algorithm::graphBreakCycles(), Sawyer::Container::IntervalMap< I, T, Policy >::values(), and Sawyer::Container::IntervalMap< I, T, Policy >::values().

◆ 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 417 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 431 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< K, T, Cmp, Alloc >::greatest(), Sawyer::Container::Map< K, T, Cmp, Alloc >::hull(), Rose::BinaryAnalysis::RegisterParts::isEmpty(), Sawyer::Container::DistinctList< T, Cmp >::isEmpty(), Sawyer::Container::IntervalMap< I, T, Policy >::isEmpty(), and Sawyer::Container::Map< K, T, Cmp, Alloc >::least().

◆ 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 443 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::isEmpty().

Referenced by Sawyer::Container::Map< K, T, Cmp, Alloc >::hull().

◆ 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 449 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::isEmpty().

Referenced by Sawyer::Container::Map< K, T, Cmp, Alloc >::hull().

◆ 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 463 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::greatest(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::Map< K, T, Cmp, Alloc >::isEmpty(), and Sawyer::Container::Map< K, T, Cmp, Alloc >::least().

◆ 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 480 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().

◆ 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 483 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

◆ 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 506 of file Sawyer/Map.h.

Referenced by Sawyer::Container::IntervalMap< I, T, Policy >::lowerBound(), and Sawyer::Container::IntervalMap< I, T, Policy >::lowerBound().

◆ 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 509 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 523 of file Sawyer/Map.h.

Referenced by Sawyer::Container::IntervalMap< I, T, Policy >::upperBound(), and Sawyer::Container::IntervalMap< I, T, Policy >::upperBound().

◆ 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 526 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 549 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::get().

◆ 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 552 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::get().

◆ 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 565 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< K, T, Cmp, Alloc >::operator[](), and Sawyer::Container::Map< K, T, Cmp, Alloc >::operator[]().

◆ 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 571 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";
Container associating values with keys.
Definition Sawyer/Map.h:72
Optional< Value > getOptional(const Key &key) const
Lookup and return a value or nothing.
Definition Sawyer/Map.h:602
Holds a value or nothing.
Definition Optional.h:56

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";
NodeIterator find(const Key &key)
Find a node by key.
Definition Sawyer/Map.h:480

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

Referenced by Sawyer::Attribute::Storage< SyncTag >::attributeOrElse(), Rose::BinaryAnalysis::Partitioner2::GraphViz::BaseEmitter< G >::emitVertex(), Sawyer::Attribute::Storage< SyncTag >::getAttribute(), Sawyer::Attribute::Storage< SyncTag >::getAttributeMaybe(), and Sawyer::Container::GraphBimapIndex< VertexOrEdgeKey, VertexOrEdgeConstIterator >::lookup().

◆ 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 614 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 618 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 629 of file Sawyer/Map.h.

Referenced by Sawyer::CommandLine::ParserResult::have(), and Rose::BinaryAnalysis::Partitioner2::GraphViz::BaseEmitter< G >::subgraphOrganization().

◆ 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

Insert or update a key/value pair.

Inserts the key/value pair into the container. If a previous node already had the same key then it is replaced by the new node. This method executes in logorithmic time.

See also
insertDefault insertMaybe insertMaybeDefault insertMultiple insertMaybeMultiple

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

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insert().

Referenced by Sawyer::Container::BiMap< S, T >::BiMap(), Rose::Color::Gradient::Gradient(), Rose::Color::Gradient::Gradient(), Rose::Color::Gradient::Gradient(), Sawyer::MultiInstanceTls< T >::MultiInstanceTls(), Sawyer::MultiInstanceTls< T >::MultiInstanceTls(), Rose::BinaryAnalysis::DataFlow::buildGraphPerVertex(), Rose::BinaryAnalysis::Partitioner2::GraphViz::BaseEmitter< G >::emit(), Sawyer::Container::IntervalMap< I, T, Policy >::erase(), Sawyer::Container::Algorithm::graphBreakCycles(), Sawyer::Container::Map< K, T, Cmp, Alloc >::insert(), Sawyer::Container::BiMap< S, T >::insert(), Sawyer::Container::GraphBimapIndex< VertexOrEdgeKey, VertexOrEdgeConstIterator >::insert(), Rose::Color::Gradient::insert(), Sawyer::Container::IntervalMap< I, T, Policy >::insert(), Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMultiple(), Sawyer::MultiInstanceTls< T >::operator=(), Sawyer::Container::DistinctList< T, Cmp >::pushBack(), Sawyer::Container::DistinctList< T, Cmp >::pushFront(), Sawyer::Attribute::Storage< SyncTag >::setAttribute(), Sawyer::Attribute::Storage< SyncTag >::setAttributeMaybe(), and Sawyer::CommandLine::EnumParser< T >::with().

◆ 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 659 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 682 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insert().

Referenced by Sawyer::Container::IntervalMap< I, T, Policy >::erase(), and Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMultiple().

◆ 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 688 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMultiple().

◆ 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 700 of file Sawyer/Map.h.

Referenced by Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybeMultiple(), and SgAsmType::registerOrDelete().

◆ 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 711 of file Sawyer/Map.h.

Referenced by Sawyer::MultiInstanceTls< T >::get(), Sawyer::MultiInstanceTls< T >::get(), Rose::BinaryAnalysis::RegisterParts::insert(), Sawyer::MultiInstanceTls< T >::operator T(), and Rose::BinaryAnalysis::Partitioner2::GraphViz::BaseEmitter< G >::subgraphOrganization().

◆ 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 722 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::insertMaybe().

◆ 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 758 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::erase().

◆ 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 771 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::erase().

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

◆ 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 775 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::keys().

◆ 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 783 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::erase().

◆ 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 797 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::erase().

Referenced by Sawyer::Container::IntervalMap< I, T, Policy >::erase().

◆ 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 802 of file Sawyer/Map.h.

References Sawyer::Container::Map< K, T, Cmp, Alloc >::erase().


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