Template Struct flex_array¶
Defined in File flex_array.hpp
Struct Documentation¶
-
template<typename T>
struct flex_array¶ arrays of undetermined, or growable length
This struct allows one to grow arrays on demand, by stringing together a linked list of short arrays of fixed length. Each instance of this struct is a segment of length segment_size, and contains pointers to the next segment and the current segment, i.e. the segment where new elements should be added.
Public Functions
-
inline flex_array(size_t _segment_size)¶
Initializes the growing array with a growth size the_segment_size.
-
inline ~flex_array()¶
Destructor.
-
inline void streamline()¶
Shrink the last segment to fit.
This method shrinks the last segment of the linked list to fit just the number of elements in it. Used for memory efficiency in the case of short arrays that were built with a larger than necessary grow size
-
inline size_t size()¶
Returns the number of elements in the array.
Public Members
-
size_t segment_size¶
number of elements in each segment
-
size_t pos¶
current position within segment
-
flex_array<T> *next¶
pointer to next segment
-
flex_array<T> *current¶
pointer to current segment
-
inline flex_array(size_t _segment_size)¶