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
| ~SparseMemMap () noexceptfinal=default
void | set (const TId id, const TValue value) final
| Set the field with id to value. More...
const TValue | get (const TId id) const final
| Retrieve value by id. Does not check for overflow or empty fields. More...
size_t | size () const noexceptfinal
size_t | used_memory () const noexceptfinal
void | clear () final
void | dump_as_list (const int fd) final
Public Member Functions inherited from osmium::index::map::Map< TId, TValue >
| Map ()=default
virtual | ~Map () noexcept=default
virtual void | reserve (const size_t)
virtual void | sort ()
virtual void | dump_as_array (const int)

## Private Attributes

std::map< TId, TValue > | m_elements

## Static Private Attributes

static constexpr size_t | element_size = sizeof(TId) + sizeof(TValue) + sizeof(void*) * 4

## Additional Inherited Members

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

## Constructor & Destructor Documentation

template<typename TId , typename TValue >

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

default

template<typename TId , typename TValue >

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

final default noexcept

## Member Function Documentation

template<typename TId , typename TValue >

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

inline final virtual

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

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

template<typename TId , typename TValue >

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

inline final virtual

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

template<typename TId , typename TValue >

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

inline final virtual

Retrieve value by id. Does not check for overflow or empty fields.

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

template<typename TId , typename TValue >

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

inline final virtual

Set the field with id to value.

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

template<typename TId , typename TValue >

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

inline final virtual noexcept

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 >.

template<typename TId , typename TValue >

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

inline final virtual noexcept

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

template<typename TId , typename TValue >

constexpr size_t osmium::index::map::SparseMemMap< TId, TValue >::element_size = sizeof(TId) + sizeof(TValue) + sizeof(void*) * 4

static private

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:

- osmium/index/map/sparse_mem_map.hpp