Loading...
Searching...
No Matches
osmium::index::map::SparseMemMap< TId, TValue > Class Template Reference

`#include <sparse_mem_map.hpp>`

Inheritance diagram for osmium::index::map::SparseMemMap< TId, TValue >:
[legend]
Collaboration diagram for osmium::index::map::SparseMemMap< TId, TValue >:
[legend]

## Public Member Functions

| SparseMemMap ()=default
void | set (const TId id, const TValue value) final
| Set the field with id to value.
TValue | get (const TId id) const final
TValue | get_noexcept (const TId id) const noexcept final
size_t | size () const noexcept final
size_t | used_memory () const noexcept final
void | clear () final
void | dump_as_list (const int fd) final
Public Member Functions inherited from osmium::index::map::Map< TId, TValue >
| Map () noexcept=default
| Map (const Map &)=delete
Map & | operator= (const Map &)=delete
virtual | ~Map () noexcept=default
virtual void | reserve (const std::size_t)
virtual void | sort ()
virtual void | dump_as_array (const int)

## Private Types

enum | { element_size = sizeof(TId) + sizeof(TValue) + (sizeof(void*) * 4U) }

## Private Attributes

std::map< TId, TValue > | m_elements

## Additional Inherited Members

Public Types inherited from osmium::index::map::Map< TId, TValue >
using | key_type = TId
| The "key" type, usually osmium::unsigned_object_id_type.
using | value_type = TValue
| The "value" type, usually a Location or size_t.
Protected Member Functions inherited from osmium::index::map::Map< TId, TValue >
| Map (Map &&) noexcept=default
Map & | operator= (Map &&) noexcept=default

## Detailed Description

template<typename TId, typename TValue>
class osmium::index::map::SparseMemMap< TId, TValue >

This implementation uses std::map internally. It uses rather a lot of memory, but might make sense for small maps.

## Member Enumeration Documentation

## anonymous enum

template<typename TId, typename TValue>

anonymous enum

private

Enumerator
element_size |

## Constructor & Destructor Documentation

## SparseMemMap()

template<typename TId, typename TValue>

osmium::index::map::SparseMemMap< TId, TValue >::SparseMemMap | ( |  | ) |

default

## Member Function Documentation

## clear()

template<typename TId, typename TValue>

void osmium::index::map::SparseMemMap< TId, TValue >::clear | ( |  | ) |

inlinefinalvirtual

Clear memory used for this storage. After this you can not use the storage container any more.

Implements osmium::index::map::Map< TId, TValue >.

## dump_as_list()

template<typename TId, typename TValue>

void osmium::index::map::SparseMemMap< TId, TValue >::dump_as_list | ( | const int | fd | ) |

inlinefinalvirtual

Reimplemented from osmium::index::map::Map< TId, TValue >.

## get()

template<typename TId, typename TValue>

TValue osmium::index::map::SparseMemMap< TId, TValue >::get | ( | const TId | id | ) | const

inlinefinalvirtual

Retrieve value by id.

Parameters

  id | The id to look for.

Returns
  Value.

Exceptions

  osmium::not_found | if the id could not be found.

Implements osmium::index::map::Map< TId, TValue >.

## get_noexcept()

template<typename TId, typename TValue>

TValue osmium::index::map::SparseMemMap< TId, TValue >::get_noexcept | ( | const TId | id | ) | const

inlinefinalvirtualnoexcept

Retrieve value by id.

Parameters

  id | The id to look for.

Returns
  Value or, if not found, the empty value as defined by osmium::index::empty_value<TValue>() which is usually the default constructed value of type TValue.

Implements osmium::index::map::Map< TId, TValue >.

## set()

template<typename TId, typename TValue>

void osmium::index::map::SparseMemMap< TId, TValue >::set | ( | const TId | id,
|  | const TValue | value )

inlinefinalvirtual

Set the field with id to value.

Implements osmium::index::map::Map< TId, TValue >.

## size()

template<typename TId, typename TValue>

size_t osmium::index::map::SparseMemMap< TId, TValue >::size | ( |  | ) | const

inlinefinalvirtualnoexcept

Get the approximate number of items in the storage. The storage might allocate memory in blocks, so this size might not be accurate. You can not use this to find out how much memory the storage uses. Use used_memory() for that.

Implements osmium::index::map::Map< TId, TValue >.

## used_memory()

template<typename TId, typename TValue>

size_t osmium::index::map::SparseMemMap< TId, TValue >::used_memory | ( |  | ) | const

inlinefinalvirtualnoexcept

Get the memory used for this storage in bytes. Note that this is not necessarily entirely accurate but an approximation. For storage classes that store the data in memory, this is the main memory used, for storage classes storing data on disk this is the memory used on disk.

Implements osmium::index::map::Map< TId, TValue >.

## Member Data Documentation

## m_elements

template<typename TId, typename TValue>

std::map<TId, TValue> osmium::index::map::SparseMemMap< TId, TValue >::m_elements

private

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

- include/osmium/index/map/sparse_mem_map.hpp