Util--  1.1
Public Types | Public Member Functions | List of all members
utilmm::hash_map< Key, Data, Hash, Equal > Class Template Reference

map with hashing access More...

#include <utilmm/hash/hash_map.hh>

Inheritance diagram for utilmm::hash_map< Key, Data, Hash, Equal >:
Inheritance graph
[legend]

Public Types

typedef Key key_type
 Key type. More...
 
typedef Data data_type
 Data type. More...
 
typedef std::pair< Key const, Data > value_type
 Value type for cells. More...
 
typedef container_type::iterator iterator
 iterator type More...
 
typedef container_type::const_iterator const_iterator
 const iterator type More...
 

Public Member Functions

void swap (hash_map &other)
 swapping function More...
 
size_t size () const
 element count More...
 
size_t max_size () const
 max element number More...
 
bool empty () const
 Emptyness test. More...
 
iterator begin ()
 beginning of table More...
 
iterator end ()
 end of table More...
 
const_iterator begin () const
 beginning of table More...
 
const_iterator end () const
 end of table More...
 
iterator find (key_arg key)
 Search for key. More...
 
const_iterator find (key_arg key) const
 Search key. More...
 
std::pair< iterator, bool > insert (value_arg val)
 Cell insertion. More...
 
void erase (iterator const &first, iterator const &last)
 Remove range. More...
 
void erase (iterator const &i)
 Remove element. More...
 
void erase (key_arg key)
 remove element More...
 
void clear ()
 Remove all elements. More...
 

Detailed Description

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
class utilmm::hash_map< Key, Data, Hash, Equal >

map with hashing access

This is an unsorted map where keys are accessed using a hash function

Parameters
Keythe key
DataThe data associated to Key
Hashhashing functor fo Key
Eqaulequality functor for Key
See also
utilmm::hash
Author
Frédéric Py fpy@l.nosp@m.aas..nosp@m.fr

Member Typedef Documentation

◆ const_iterator

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
typedef container_type::const_iterator utilmm::hash_map< Key, Data, Hash, Equal >::const_iterator

const iterator type

const iterator type The type used to iterate through this class without any modification

◆ data_type

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
typedef Data utilmm::hash_map< Key, Data, Hash, Equal >::data_type

Data type.

This is the type of the data asociated to the key

◆ iterator

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
typedef container_type::iterator utilmm::hash_map< Key, Data, Hash, Equal >::iterator

iterator type

iterator type The type used to iterate through and manipulate this class

◆ key_type

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
typedef Key utilmm::hash_map< Key, Data, Hash, Equal >::key_type

Key type.

◆ value_type

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
typedef std::pair<Key const, Data> utilmm::hash_map< Key, Data, Hash, Equal >::value_type

Value type for cells.

Value type for cells.

For hash_map value_type is a std::pair containing the key and the associated data.

Member Function Documentation

◆ begin() [1/2]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
iterator utilmm::hash_map< Key, Data, Hash, Equal >::begin ( )
inline

beginning of table

Beginning of table.

Returns
an iterator pointing to the beginning of the container
See also
end()

◆ begin() [2/2]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
const_iterator utilmm::hash_map< Key, Data, Hash, Equal >::begin ( ) const
inline

beginning of table

Beginning of table.

Returns
a const iterator pointing to the beginning of the container
See also
end() const

◆ clear()

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
void utilmm::hash_map< Key, Data, Hash, Equal >::clear ( )
inline

Remove all elements.

remove all elements This function is strictly equivelent to erase(begin(), end())

Referenced by utilmm::cached_fn< Arg, Ret, Hash, Equal >::empty_cache().

◆ empty()

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
bool utilmm::hash_map< Key, Data, Hash, Equal >::empty ( ) const
inline

Emptyness test.

Emptyness test.

Return values
trueif this instance has no element
falseelse
See also
size() const

◆ end() [1/2]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
iterator utilmm::hash_map< Key, Data, Hash, Equal >::end ( )
inline

end of table

End of table.

Returns
an iterator pointing to the end of the container
See also
begin()

Referenced by utilmm::hash_map< base_type *, size_t, hash_ptr< Ty, Hash >, eq_ptr< Ty, Equal > >::erase(), and utilmm::smart::ref_count::uniq_memory< Ty, Hash, Equal >::null_cell().

◆ end() [2/2]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
const_iterator utilmm::hash_map< Key, Data, Hash, Equal >::end ( ) const
inline

end of table

End of table.

Returns
an iterator pointing to the end of the container
See also
begin()

◆ erase() [1/3]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
void utilmm::hash_map< Key, Data, Hash, Equal >::erase ( iterator const &  first,
iterator const &  last 
)
inline

Remove range.

Remove elements.

Parameters
firstan iterator
lastan iterator

removes all the element of the table in the range [first, last [

Referenced by utilmm::hash_map< base_type *, size_t, hash_ptr< Ty, Hash >, eq_ptr< Ty, Equal > >::erase().

◆ erase() [2/3]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
void utilmm::hash_map< Key, Data, Hash, Equal >::erase ( iterator const &  i)
inline

Remove element.

Parameters
iThe lement to remove

This function removes the element pointed by i form the table

◆ erase() [3/3]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
void utilmm::hash_map< Key, Data, Hash, Equal >::erase ( key_arg  key)
inline

remove element

Parameters
keythe key of the element

This function erase, if any, the element whose key is key

◆ find() [1/2]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
iterator utilmm::hash_map< Key, Data, Hash, Equal >::find ( key_arg  key)
inline

Search for key.

Parameters
keythe key to find.

This function tries to search in table an element with key key

Returns
An iterator pointing to the element with key key or end() if not found.

Referenced by utilmm::hash_map< base_type *, size_t, hash_ptr< Ty, Hash >, eq_ptr< Ty, Equal > >::erase().

◆ find() [2/2]

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
const_iterator utilmm::hash_map< Key, Data, Hash, Equal >::find ( key_arg  key) const
inline

Search key.

Search for key.

Parameters
keythe key to find.

This function tries to search in table an element with key key

Returns
An iterator pointing to the element with key key or end() if not found.

◆ insert()

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
std::pair<iterator, bool> utilmm::hash_map< Key, Data, Hash, Equal >::insert ( value_arg  val)
inline

Cell insertion.

Parameters
valThe value to insert

This function tries to insert val in current instance. It will not insert it if ther's already a cell with the same key as val

Returns
A pair where first is an iterator pointing to cell with the same key as val and second is true if and only if val was inserted.

◆ max_size()

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
size_t utilmm::hash_map< Key, Data, Hash, Equal >::max_size ( ) const
inline

max element number

max elmement number

Returns
The maximum possible number of elements

◆ size()

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
size_t utilmm::hash_map< Key, Data, Hash, Equal >::size ( ) const
inline

element count

element count

Returns
the number of element present in current container

Referenced by utilmm::cached_fn< Arg, Ret, Hash, Equal >::cache_size().

◆ swap()

template<typename Key, typename Data, class Hash = hash<Key>, class Equal = std::equal_to<Key>>
void utilmm::hash_map< Key, Data, Hash, Equal >::swap ( hash_map< Key, Data, Hash, Equal > &  other)
inline

swapping function

swapping values function This function exchange the value of current instance with the value of another instance.

Parameters
otherThe other instance

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

Generated on Mon Sep 24 2018 17:06:40 for Util-- by doxygen 1.8.13
SourceForge.net Project Page