DSC
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
is_mesh::kernel< key_type, value_type > Class Template Reference

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

Detailed Description

template<typename key_type, typename value_type>
class is_mesh::kernel< key_type, value_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.

Parameters
value_typeThe type of the elements that is to be stored in the kernel. The value_type must have the typedef type_traits.
key_typeThe type of the keys used in the kernel. Should be an integer type.

Constructor & Destructor Documentation

template<typename key_type, typename value_type>
is_mesh::kernel< key_type, value_type >::kernel ( size_t  reservedSize = 64)
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.

Parameters
reservedSizeThe initial capacity of the kernel.
template<typename key_type, typename value_type>
is_mesh::kernel< key_type, value_type >::~kernel ( )
inline

Kernel destructor, frees allocated memory by the kernel.

Member Function Documentation

template<typename key_type, typename value_type>
const_iterator is_mesh::kernel< key_type, value_type >::begin ( ) const
inline

Returns an iterator to the first element of the kernel.

template<typename key_type, typename value_type>
size_t is_mesh::kernel< key_type, value_type >::capacity ( ) const
inline

The capacity of the kernel. Note not all elements may in use.

template<typename key_type, typename value_type>
void is_mesh::kernel< key_type, value_type >::clear ( )
inline

Permanently deletes all elements in the kernel and resets all internal lists and stacks.

template<typename key_type, typename value_type>
std::vector<key_type> is_mesh::kernel< key_type, value_type >::commit_all ( )
inline

Commits all the changes in the kernel, and permanently removes all the marked elements.

template<typename key_type, typename value_type>
template<typename... Values>
const_iterator is_mesh::kernel< key_type, value_type >::create ( ISMesh isMesh,
Values...  values 
)
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.

Parameters
attributesThe type traits of the element to be inserted.
Returns
An iterator pointing to the element.
template<typename key_type, typename value_type>
char* is_mesh::kernel< key_type, value_type >::data ( )
inline

Returns pointer to the underlying array serving as element storage.

template<typename key_type, typename value_type>
bool is_mesh::kernel< key_type, value_type >::empty ( )
inline

Returns a boolean value indicating if the size is zero.

template<typename key_type, typename value_type>
const_iterator is_mesh::kernel< key_type, value_type >::end ( ) const
inline

Returns the one-past-the-end iterator to the kernel.

template<typename key_type, typename value_type>
void is_mesh::kernel< key_type, value_type >::erase ( key_type const &  k)
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.

Parameters
kThe key or handle to the element to be deleted.
template<typename key_type, typename value_type>
void is_mesh::kernel< key_type, value_type >::erase ( const iterator it)
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.

Parameters
itAn iterator pointing to an element in the kernel.
template<typename key_type, typename value_type>
iterator is_mesh::kernel< key_type, value_type >::find_iterator ( key_type  k)
inline

Converts a key or handle to an iterator pointing to the same cell.

Parameters
kThe handle of the cell.
template<typename key_type, typename value_type>
iterator is_mesh::kernel< key_type, value_type >::find_valid_iterator ( key_type  k)
inline

Converts a key or handle to an iterator pointing to the same cell.

Parameters
kThe handle of the cell.
template<typename key_type, typename value_type>
std::vector<key_type> is_mesh::kernel< key_type, value_type >::garbage_collect ( )
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).

template<typename key_type, typename value_type>
value_type& is_mesh::kernel< key_type, value_type >::get ( key_type  k)
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.

Parameters
kThe handle to the object.
template<typename key_type, typename value_type>
const value_type& is_mesh::kernel< key_type, value_type >::get ( key_type  k) const
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.

Parameters
kThe handle to the object.
template<typename key_type, typename value_type>
bool is_mesh::kernel< key_type, value_type >::is_excluded ( key_type  k)
inline

Returns true if element is excluded

template<typename key_type, typename value_type>
bool is_mesh::kernel< key_type, value_type >::is_valid ( key_type  k)
inline

Returns the status of the cell given its key.

Parameters
kThe handle to the object.
Returns
True if the object is a valid (including excluded) element, false if it is marked for deletion or k refers to an empty cell.
template<typename key_type, typename value_type>
size_t is_mesh::kernel< key_type, value_type >::size ( ) const
inline

The size of the kernel. That is the number of valid elements in the kernel.


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