ROSE 0.11.145.192
Classes | Public Types | Public Member Functions | List of all members
Sawyer::Container::HashMap< K, T, H, C, A > Class Template Reference

Description

template<class K, class T, class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
class Sawyer::Container::HashMap< K, T, H, C, A >

Container associating values with keys.

This container is similar to TL's unordered_map in that it stores a value for each key using a hash-based mechanism, although it works for C++ versions before C++11. The naming scheme is similar to other Sawyer containers. If you're used to the STL, the main differences are described in the documentation for the Sawyer::Container name space.

See also, Map.

Definition at line 30 of file HashMap.h.

#include <Sawyer/HashMap.h>

Inheritance diagram for Sawyer::Container::HashMap< K, T, H, C, A >:
Inheritance graph
[legend]

Classes

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

Public Types

typedef K Key
 Type of keys.
 
typedef T Value
 Type of values.
 
typedef H Hasher
 Functor for hashing keys.
 
typedef C Comparator
 Functor for comparing keys.
 
typedef A Allocator
 Functor for allocating node memory.
 

Public Member Functions

 HashMap ()
 Default constructor.
 
 HashMap (size_t n, const Hasher &hasher=Hasher(), const Comparator &cmp=Comparator(), const Allocator &alloc=Allocator())
 Constructs a hash map with at least n buckets.
 
 HashMap (const HashMap &other)
 Copy constructor.
 
template<class K2 , class T2 , class H2 , class C2 , class A2 >
 HashMap (const HashMap< K2, T2, H2, C2, A2 > &other)
 Copy constructor.
 
template<class K2 , class T2 , class H2 , class C2 , class A2 >
HashMapoperator= (const HashMap< K2, T2, H2, C2, A2 > &other)
 Assignment operator.
 
bool isEmpty () const
 Determine whether this container is empty.
 
size_t size () const
 Number of nodes, keys, or values in this container.
 
size_t nBuckets () const
 Number of buckets.
 
double loadFactor () const
 Average number of nodes per bucket.
 
void rehash (size_t nBuckets)
 Change number of buckets.
 
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.
 
HashMapinsert (const Key &key, const Value &value)
 Insert or update a key/value pair.
 
HashMapinsertDefault (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 >
HashMapinsertMaybeMultiple (const boost::iterator_range< OtherNodeIterator > &range)
 Conditionally insert multiple key/value pairs.
 
HashMapclear ()
 Remove all nodes.
 
HashMaperase (const Key &key)
 Remove a node with specified key.
 
template<class OtherKeyIterator >
HashMaperaseMultiple (const boost::iterator_range< OtherKeyIterator > &range)
 Remove keys stored in another HashMap.
 
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.
 
double maxLoadFactor () const
 Property: Maximum allowed load faster before automatic rehash.
 
void maxLoadFactor (double mlf)
 Property: Maximum allowed load faster before automatic rehash.
 
NodeIterator find (const Key &key)
 Find a node by key.
 
ConstNodeIterator find (const Key &key) const
 Find a node by 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 retun an existing value.
 
const Valueget (const Key &key) const
 Lookup and retun 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 >
HashMapinsertMultiple (const OtherNodeIterator &begin, const OtherNodeIterator &end)
 Insert multiple values.
 
template<class OtherNodeIterator >
HashMapinsertMultiple (const boost::iterator_range< OtherNodeIterator > &range)
 Insert multiple values.
 
HashMaperaseAt (const NodeIterator &iter)
 Remove a node by iterator.
 
HashMaperaseAt (const ConstKeyIterator &iter)
 Remove a node by iterator.
 
HashMaperaseAt (const ValueIterator &iter)
 Remove a node by iterator.
 
template<class Iter >
HashMaperaseAtMultiple (const Iter &begin, const Iter &end)
 Remove multiple nodes by iterator range.
 
template<class Iter >
HashMaperaseAtMultiple (const boost::iterator_range< Iter > &range)
 Remove multiple nodes by iterator range.
 

Member Typedef Documentation

◆ Key

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
typedef K Sawyer::Container::HashMap< K, T, H, C, A >::Key

Type of keys.

Definition at line 32 of file HashMap.h.

◆ Value

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
typedef T Sawyer::Container::HashMap< K, T, H, C, A >::Value

Type of values.

Definition at line 33 of file HashMap.h.

◆ Hasher

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
typedef H Sawyer::Container::HashMap< K, T, H, C, A >::Hasher

Functor for hashing keys.

Definition at line 34 of file HashMap.h.

◆ Comparator

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
typedef C Sawyer::Container::HashMap< K, T, H, C, A >::Comparator

Functor for comparing keys.

Definition at line 35 of file HashMap.h.

◆ Allocator

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
typedef A Sawyer::Container::HashMap< K, T, H, C, A >::Allocator

Functor for allocating node memory.

Definition at line 36 of file HashMap.h.

Constructor & Destructor Documentation

◆ HashMap() [1/4]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Sawyer::Container::HashMap< K, T, H, C, A >::HashMap ( )
inline

Default constructor.

Creates an empty map.

Definition at line 253 of file HashMap.h.

◆ HashMap() [2/4]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Sawyer::Container::HashMap< K, T, H, C, A >::HashMap ( size_t  n,
const Hasher hasher = Hasher(),
const Comparator cmp = Comparator(),
const Allocator alloc = Allocator() 
)
inline

Constructs a hash map with at least n buckets.

Definition at line 256 of file HashMap.h.

◆ HashMap() [3/4]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Sawyer::Container::HashMap< K, T, H, C, A >::HashMap ( const HashMap< K, T, H, C, A > &  other)
inline

Copy constructor.

Definition at line 260 of file HashMap.h.

◆ HashMap() [4/4]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class K2 , class T2 , class H2 , class C2 , class A2 >
Sawyer::Container::HashMap< K, T, H, C, A >::HashMap ( const HashMap< K2, T2, H2, C2, A2 > &  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 ohter map to this map.

Definition at line 268 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::nodes().

Member Function Documentation

◆ operator=()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class K2 , class T2 , class H2 , class C2 , class A2 >
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::operator= ( const HashMap< K2, T2, H2, C2, A2 > &  other)
inline

◆ nodes() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
boost::iterator_range< NodeIterator > Sawyer::Container::HashMap< K, T, H, C, A >::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 296 of file HashMap.h.

Referenced by Sawyer::Container::HashMap< K, T, H, C, A >::HashMap(), and Sawyer::Container::HashMap< K, T, H, C, A >::operator=().

◆ nodes() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
boost::iterator_range< ConstNodeIterator > Sawyer::Container::HashMap< K, T, H, C, A >::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 299 of file HashMap.h.

◆ keys() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
boost::iterator_range< ConstKeyIterator > Sawyer::Container::HashMap< K, T, H, C, A >::keys ( )
inline

Iterators for container keys.

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

Definition at line 309 of file HashMap.h.

◆ keys() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
boost::iterator_range< ConstKeyIterator > Sawyer::Container::HashMap< K, T, H, C, A >::keys ( ) const
inline

Iterators for container keys.

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

Definition at line 312 of file HashMap.h.

◆ values() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
boost::iterator_range< ValueIterator > Sawyer::Container::HashMap< K, T, H, C, A >::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 323 of file HashMap.h.

◆ values() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
boost::iterator_range< ConstValueIterator > Sawyer::Container::HashMap< K, T, H, C, A >::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 326 of file HashMap.h.

◆ isEmpty()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
bool Sawyer::Container::HashMap< K, T, H, C, A >::isEmpty ( ) const
inline

Determine 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 339 of file HashMap.h.

◆ size()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
size_t Sawyer::Container::HashMap< K, T, H, C, A >::size ( ) const
inline

Number of nodes, keys, or values in this container.

Returns the number of nodes currently stored in this container. A node is a key + value pair. This method executes in constant time.

Definition at line 347 of file HashMap.h.

Referenced by Rose::BinaryAnalysis::InstructionProvider::nCached().

◆ nBuckets()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
size_t Sawyer::Container::HashMap< K, T, H, C, A >::nBuckets ( ) const
inline

Number of buckets.

Definition at line 352 of file HashMap.h.

Referenced by Sawyer::Container::HashMap< K, T, H, C, A >::rehash().

◆ loadFactor()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
double Sawyer::Container::HashMap< K, T, H, C, A >::loadFactor ( ) const
inline

Average number of nodes per bucket.

Definition at line 357 of file HashMap.h.

◆ maxLoadFactor() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
double Sawyer::Container::HashMap< K, T, H, C, A >::maxLoadFactor ( ) const
inline

Property: Maximum allowed load faster before automatic rehash.

Definition at line 364 of file HashMap.h.

◆ maxLoadFactor() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
void Sawyer::Container::HashMap< K, T, H, C, A >::maxLoadFactor ( double  mlf)
inline

Property: Maximum allowed load faster before automatic rehash.

Definition at line 367 of file HashMap.h.

◆ rehash()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
void Sawyer::Container::HashMap< K, T, H, C, A >::rehash ( size_t  nBuckets)
inline

Change number of buckets.

Definition at line 373 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::nBuckets().

◆ find() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
NodeIterator Sawyer::Container::HashMap< K, T, H, C, A >::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.

Definition at line 388 of file HashMap.h.

◆ find() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
ConstNodeIterator Sawyer::Container::HashMap< K, T, H, C, A >::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.

Definition at line 391 of file HashMap.h.

◆ exists()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
bool Sawyer::Container::HashMap< K, T, H, C, A >::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.

Definition at line 400 of file HashMap.h.

◆ operator[]() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Value & Sawyer::Container::HashMap< K, T, H, C, A >::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 421 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::get().

◆ operator[]() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
const Value & Sawyer::Container::HashMap< K, T, H, C, A >::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 424 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::get().

◆ get() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Value & Sawyer::Container::HashMap< K, T, H, C, A >::get ( const Key key)
inline

Lookup and retun 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 437 of file HashMap.h.

Referenced by Sawyer::Container::HashMap< K, T, H, C, A >::operator[](), and Sawyer::Container::HashMap< K, T, H, C, A >::operator[]().

◆ get() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
const Value & Sawyer::Container::HashMap< K, T, H, C, A >::get ( const Key key) const
inline

Lookup and retun 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 443 of file HashMap.h.

◆ getOptional()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Optional< Value > Sawyer::Container::HashMap< K, T, H, C, A >::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.

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 HashMap.h:30
Optional< Value > getOptional(const Key &key) const
Lookup and return a value or nothing.
Definition HashMap.h:473
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 HashMap.h:388

Definition at line 473 of file HashMap.h.

◆ getOrElse() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Value & Sawyer::Container::HashMap< K, T, H, C, A >::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 485 of file HashMap.h.

◆ getOrElse() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
const Value & Sawyer::Container::HashMap< K, T, H, C, A >::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 489 of file HashMap.h.

◆ getOrDefault()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
const Value & Sawyer::Container::HashMap< K, T, H, C, A >::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 499 of file HashMap.h.

◆ insert()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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.

See also
insertDefault insertMaybe insertMaybeDefault insertMultiple insertMaybeMultiple

Definition at line 516 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::insert().

Referenced by Sawyer::Container::HashMap< K, T, H, C, A >::insert(), Sawyer::Container::HashMap< K, T, H, C, A >::insertDefault(), and Sawyer::Container::HashMap< K, T, H, C, A >::insertMultiple().

◆ insertDefault()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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 529 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::insert().

◆ insertMultiple() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class OtherNodeIterator >
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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:

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

Definition at line 551 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::insert().

Referenced by Sawyer::Container::HashMap< K, T, H, C, A >::insertMultiple().

◆ insertMultiple() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class OtherNodeIterator >
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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:

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

Definition at line 557 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::insertMultiple().

◆ insertMaybe()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Value & Sawyer::Container::HashMap< K, T, H, C, A >::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. 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 569 of file HashMap.h.

Referenced by Sawyer::Container::HashMap< K, T, H, C, A >::insertMaybeDefault(), and Sawyer::Container::HashMap< K, T, H, C, A >::insertMaybeMultiple().

◆ insertMaybeDefault()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
Value & Sawyer::Container::HashMap< K, T, H, C, A >::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. 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 580 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::insertMaybe().

◆ insertMaybeMultiple()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class OtherNodeIterator >
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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 591 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::insertMaybe().

◆ clear()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::clear ( )
inline

Remove all nodes.

All nodes are removed from this container. This method executes in linear time in the number of nodes in this container.

Definition at line 601 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::clear().

Referenced by Sawyer::Container::HashMap< K, T, H, C, A >::clear(), and Sawyer::Container::HashMap< K, T, H, C, A >::operator=().

◆ erase()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::erase ( const Key key)
inline

◆ eraseMultiple()

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class OtherKeyIterator >
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::eraseMultiple ( const boost::iterator_range< OtherKeyIterator > &  range)
inline

Remove keys stored in another HashMap.

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.

See also
erase eraseAt eraseAtMultiple

Definition at line 625 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::erase().

◆ eraseAt() [1/3]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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 638 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::erase().

◆ eraseAt() [2/3]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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 642 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::erase().

◆ eraseAt() [3/3]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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 646 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::erase().

◆ eraseAtMultiple() [1/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class Iter >
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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 660 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::erase().

◆ eraseAtMultiple() [2/2]

template<class K , class T , class H = boost::hash<K>, class C = std::equal_to<K>, class A = std::allocator<std::pair<const K, T> >>
template<class Iter >
HashMap & Sawyer::Container::HashMap< K, T, H, C, A >::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 665 of file HashMap.h.

References Sawyer::Container::HashMap< K, T, H, C, A >::erase().


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