#include <kernel.h>
Public Types | |
using | kernel_type = kernel< key_type, value_type > |
using | kernel_key_type = key_type |
using | kernel_element = util::kernel_element< key_type, value_type > |
using | iterator = kernel_iterator< kernel_type > |
using | const_iterator = iterator const |
Public Member Functions | |
kernel (size_t reservedSize=64) | |
~kernel () | |
size_t | size () const |
size_t | capacity () const |
bool | empty () |
template<typename... Values> | |
const_iterator | create (ISMesh *isMesh, Values...values) |
const_iterator | end () const |
const_iterator | begin () const |
void | erase (key_type const &k) |
void | erase (const iterator &it) |
void | clear () |
iterator | find_iterator (key_type k) |
iterator | find_valid_iterator (key_type k) |
value_type & | get (key_type k) |
const value_type & | get (key_type k) const |
char * | data () |
bool | is_valid (key_type k) |
bool | is_excluded (key_type k) |
std::vector< key_type > | commit_all () |
void | revert_excluded () |
void | exclude_using_include_set (std::set< key_type > include_set) |
std::vector< key_type > | garbage_collect () |
Public Attributes | |
bool | readonly = false |
Friends | |
class | kernel_iterator< kernel_type > |
Memory Kernel developed for the DSC project. The kernel uses the supplied allocator to allocate memory for data structures, like the IS mesh used in DSC. The kernel uses array-based allocation. The kernel supports undo operations. Each cell in the kernel uses an excess of 12 bytes, which is used to support fast iterators through the kernel and the undo functionality.
value_type | The type of the elements that is to be stored in the kernel. The value_type must have the typedef type_traits. |
key_type | The type of the keys used in the kernel. Should be an integer type. |
|
inline |
Default constructor for the kernel. This will initialize all lists and memory used by the kernel. The initial should always be greater than 0.
reservedSize | The initial capacity of the kernel. |
|
inline |
Kernel destructor, frees allocated memory by the kernel.
|
inline |
Returns an iterator to the first element of the kernel.
|
inline |
The capacity of the kernel. Note not all elements may in use.
|
inline |
Permanently deletes all elements in the kernel and resets all internal lists and stacks.
|
inline |
Commits all the changes in the kernel, and permanently removes all the marked elements.
|
inline |
Creates (or inserts) a new element into the kernel. From this point forward the memory management of the element is controlled by the kernel.
attributes | The type traits of the element to be inserted. |
|
inline |
Returns pointer to the underlying array serving as element storage.
|
inline |
Returns a boolean value indicating if the size is zero.
|
inline |
Returns the one-past-the-end iterator to the kernel.
|
inline |
Deletes an element in the kernel. The element is not actually deleted, it is merely marked for deletion. If no element is found in the cell nothing is performed.
k | The key or handle to the element to be deleted. |
|
inline |
Deletes an element in the kernel. The element is not actually deleted, it is merely marked for deletion. If no element is found in the cell nothing is performed.
it | An iterator pointing to an element in the kernel. |
|
inline |
Converts a key or handle to an iterator pointing to the same cell.
k | The handle of the cell. |
|
inline |
Converts a key or handle to an iterator pointing to the same cell.
k | The handle of the cell. |
|
inline |
Commits all changes and permanently deletes all marked elements. The garbage collect routine performs one functions. First it commits all changes on the undo stack and clears all undo marks. The operation runs in O(n) - where n is m_capacity or the size of allocated memory (not efficient, but cleans lists).
|
inline |
Returns a managed object. Beware of deallocating or other memory handlings of the returned object, as this might lead to undefined behavior in the kernel.
k | The handle to the object. |
|
inline |
Returns a managed object. Beware of deallocating or other memory handlings of the returned object, as this might lead to undefined behavior in the kernel.
k | The handle to the object. |
|
inline |
Returns true if element is excluded
|
inline |
Returns the status of the cell given its key.
k | The handle to the object. |
|
inline |
The size of the kernel. That is the number of valid elements in the kernel.