|
Libosmium
Fast and flexible C++ library for working with OpenStreetMap data
|
#include <item_stash.hpp>
Classes | |
| class | handle_type |
| class | cleanup_helper |
Public Member Functions | |
| ItemStash () | |
| std::size_t | used_memory () const noexcept |
| std::size_t | size () const noexcept |
| std::size_t | count_removed () const noexcept |
| void | clear () |
| handle_type | add_item (const osmium::memory::Item &item) |
| osmium::memory::Item & | get_item (handle_type handle) const |
| template<typename T> | |
| T & | get (handle_type handle) const |
| void | garbage_collect () |
| void | remove_item (handle_type handle) |
Private Types | |
| enum | { initial_buffer_size = 1024UL * 1024UL } |
| enum | { removed_item_offset = std::numeric_limits<std::size_t>::max() } |
Private Member Functions | |
| std::size_t & | get_item_offset_ref (handle_type handle) noexcept |
| std::size_t | get_item_offset (handle_type handle) const noexcept |
| bool | should_gc () const noexcept |
Private Attributes | |
| osmium::memory::Buffer | m_buffer |
| std::vector< std::size_t > | m_index |
| std::size_t | m_count_items = 0 |
| std::size_t | m_count_removed = 0 |
Class for storing OSM data in memory. Any osmium::memory::Item can be added to the stash and it will be copied into its internal Buffer. To access the item again, an opaque handle is used.
|
inline |
|
inline |
Add an item to the stash. This will invalidate any pointers and references into the stash, but handles are still valid.
Complexity: Amortized constant.
|
inline |
Clear all items from the stash. This will not necessarily release any memory. All handles are invalidated.
|
inlinenoexcept |
The number of removed items currently still taking up memory in the stash. You can call garbage_collect() to remove them.
Complexity: Constant.
|
inline |
Garbage collect the memory used by the ItemStash. This will free up memory for adding new items. No memory is actually returned to the OS. Usually you do not need to call this, because add_item() will call it for you as necessary.
Complexity: Linear in size() + count_removed().
|
inline |
Get a reference to an item in the stash. Note that this reference will be invalidated by any add_item() or clear() calls.
Complexity: Constant.
| handle | A handle returned by add_item(). |
| T | Type you want to the data to be interpreted as. You must be sure that the item has the specified type, this will not be checked! |
|
inline |
Get a reference to an item in the stash. Note that this reference will be invalidated by any add_item() or clear() calls.
Complexity: Constant.
| handle | A handle returned by add_item(). |
|
inlineprivatenoexcept |
|
inlineprivatenoexcept |
|
inline |
Remove an item from the stash. The item will be marked as removed and the handle will be invalidated. No memory will actually be freed.
Complexity: Constant.
| handle | A handle returned by add_item(). |
|
inlineprivatenoexcept |
|
inlinenoexcept |
The number of items currently in the stash. This is the number added minus the number removed.
Complexity: Constant.
|
inlinenoexcept |
Return an estimate of the number of bytes currently used by this ItemStash instance.
Complexity: Constant.
|
private |
|
private |
|
private |
|
private |