#include <item_stash.hpp>
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.
◆ anonymous enum
Enumerator |
---|
initial_buffer_size | |
◆ anonymous enum
Enumerator |
---|
removed_item_offset | |
◆ ItemStash()
osmium::ItemStash::ItemStash |
( |
| ) |
|
|
inline |
◆ add_item()
Add an item to the stash. This will invalidate any pointers and references into the stash, but handles are still valid.
Complexity: Amortized constant.
◆ clear()
void osmium::ItemStash::clear |
( |
| ) |
|
|
inline |
Clear all items from the stash. This will not necessarily release any memory. All handles are invalidated.
◆ count_removed()
std::size_t osmium::ItemStash::count_removed |
( |
| ) |
const |
|
inlinenoexcept |
The number of removed items currently still taking up memory in the stash. You can call garbage_collect() to remove them.
Complexity: Constant.
◆ garbage_collect()
void osmium::ItemStash::garbage_collect |
( |
| ) |
|
|
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().
◆ get()
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.
- Parameters
-
- Template Parameters
-
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! |
- Returns
- Reference of given type pointing to the data in the stash.
- Precondition
- Handle must be a valid handle and referring to a non-removed item.
◆ get_item()
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.
- Parameters
-
- Precondition
- Handle must be a valid handle and referring to a non-removed item.
◆ get_item_offset()
std::size_t osmium::ItemStash::get_item_offset |
( |
handle_type |
handle | ) |
const |
|
inlineprivatenoexcept |
◆ get_item_offset_ref()
std::size_t & osmium::ItemStash::get_item_offset_ref |
( |
handle_type |
handle | ) |
|
|
inlineprivatenoexcept |
◆ remove_item()
void osmium::ItemStash::remove_item |
( |
handle_type |
handle | ) |
|
|
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.
- Parameters
-
- Precondition
- Handle must be a valid handle and referring to a non-removed item.
◆ should_gc()
bool osmium::ItemStash::should_gc |
( |
| ) |
const |
|
inlineprivatenoexcept |
◆ size()
std::size_t osmium::ItemStash::size |
( |
| ) |
const |
|
inlinenoexcept |
The number of items currently in the stash. This is the number added minus the number removed.
Complexity: Constant.
◆ used_memory()
std::size_t osmium::ItemStash::used_memory |
( |
| ) |
const |
|
inlinenoexcept |
Return an estimate of the number of bytes currently used by this ItemStash instance.
Complexity: Constant.
◆ m_buffer
osmium::memory::Buffer osmium::ItemStash::m_buffer |
|
private |
◆ m_count_items
std::size_t osmium::ItemStash::m_count_items = 0 |
|
private |
◆ m_count_removed
std::size_t osmium::ItemStash::m_count_removed = 0 |
|
private |
◆ m_index
std::vector<std::size_t> osmium::ItemStash::m_index |
|
private |
The documentation for this class was generated from the following file: