Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE > Class Template Reference

#include <short_value_optimized_storage.h>

Public Member Functions

 ShortValueOptimizedStorage (const uint32_t capacity, const uint32_t short_value_upper_bound)
 
 ~ShortValueOptimizedStorage ()
 
 ShortValueOptimizedStorage (ShortValueOptimizedStorage &&other)=default
 
ShortValueOptimizedStorageoperator= (ShortValueOptimizedStorage &&other)=default
 
 ShortValueOptimizedStorage (const ShortValueOptimizedStorage &other)=delete
 
ShortValueOptimizedStorageoperator= (const ShortValueOptimizedStorage &other)=delete
 
uint32_t num_values () const
 Returns the number of values in the container. More...
 
uint32_t capacity () const
 Returns the maximum number of values the container can hold. More...
 
uint32_t max_value_length () const
 Returns the length of the longest value in the container. More...
 
uint32_t value_length (const uint32_t index) const
 Returns the length of the value at the specified position. More...
 
bool is_set (const uint32_t index) const
 Determines whether there is a value at the specified position. More...
 
std::pair< ELEMENT_TYPE
*, uint32_t > 
get (const uint32_t index) const
 Gets the value stored at a specified index (first of pair) plus its length in number of items (second of pair) More...
 
void set (const uint32_t index, const std::vector< ELEMENT_TYPE > &values)
 Set the value at the specified index by vector. More...
 
void set (const uint32_t index, const ELEMENT_TYPE *values, const uint32_t num_values)
 Set the value at the specified index by pointer. More...
 
void clear (const uint32_t index)
 Clear the value at a specific index. More...
 
void clear ()
 Reset storage to a pristine state with no values. More...
 

Detailed Description

template<class ELEMENT_TYPE>
class gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >

A class for storing arrays of values of varying lengths, optimizing for short arrays (where "short" is custom-defined). "Short" arrays are stored in preallocated contiguous storage, while arrays that don't fit in contiguous storage are dynamically allocated. The idea is to preserve data locality and avoid new memory allocations/deallocations as much as possible. Performance should be good provided that most arrays fall into the "short" category.

This is intended as a more-efficient replacement for vector<vector> in cases where typical inner vector lengths are known in advance.

Constructor & Destructor Documentation

template<class ELEMENT_TYPE>
gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::ShortValueOptimizedStorage ( const uint32_t  capacity,
const uint32_t  short_value_upper_bound 
)
inline
template<class ELEMENT_TYPE>
gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::~ShortValueOptimizedStorage ( )
inline
template<class ELEMENT_TYPE>
gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::ShortValueOptimizedStorage ( ShortValueOptimizedStorage< ELEMENT_TYPE > &&  other)
default
template<class ELEMENT_TYPE>
gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::ShortValueOptimizedStorage ( const ShortValueOptimizedStorage< ELEMENT_TYPE > &  other)
delete

Member Function Documentation

template<class ELEMENT_TYPE>
uint32_t gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::capacity ( ) const
inline

Returns the maximum number of values the container can hold.

template<class ELEMENT_TYPE>
void gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::clear ( const uint32_t  index)
inline

Clear the value at a specific index.

Note
may require us to recalculate the length of the longest value in storage
template<class ELEMENT_TYPE>
void gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::clear ( )
inline

Reset storage to a pristine state with no values.

template<class ELEMENT_TYPE>
std::pair<ELEMENT_TYPE*,uint32_t> gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::get ( const uint32_t  index) const
inline

Gets the value stored at a specified index (first of pair) plus its length in number of items (second of pair)

template<class ELEMENT_TYPE>
bool gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::is_set ( const uint32_t  index) const
inline

Determines whether there is a value at the specified position.

template<class ELEMENT_TYPE>
uint32_t gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::max_value_length ( ) const
inline

Returns the length of the longest value in the container.

template<class ELEMENT_TYPE>
uint32_t gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::num_values ( ) const
inline

Returns the number of values in the container.

template<class ELEMENT_TYPE>
ShortValueOptimizedStorage& gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::operator= ( ShortValueOptimizedStorage< ELEMENT_TYPE > &&  other)
default
template<class ELEMENT_TYPE>
ShortValueOptimizedStorage& gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::operator= ( const ShortValueOptimizedStorage< ELEMENT_TYPE > &  other)
delete
template<class ELEMENT_TYPE>
void gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::set ( const uint32_t  index,
const std::vector< ELEMENT_TYPE > &  values 
)
inline

Set the value at the specified index by vector.

template<class ELEMENT_TYPE>
void gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::set ( const uint32_t  index,
const ELEMENT_TYPE *  values,
const uint32_t  num_values 
)
inline

Set the value at the specified index by pointer.

template<class ELEMENT_TYPE>
uint32_t gamgee::utils::ShortValueOptimizedStorage< ELEMENT_TYPE >::value_length ( const uint32_t  index) const
inline

Returns the length of the value at the specified position.


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