A slice of contiguous memory, prefixed by and header containing size and capacity.
More...
|
|
| Segment (uint32_t capacityInBytes, SegmentAllocator allocator=SegmentAllocator::Global) noexcept |
| |
|
| Segment (Segment &&other) noexcept |
| |
|
| Segment (const Segment &other) noexcept |
| |
|
Segment & | operator= (Segment &&other) noexcept |
| |
|
Segment & | operator= (const Segment &other) noexcept |
| |
|
template<typename U = T> |
| | Segment (Span< const U > span) noexcept |
| |
|
| Segment (std::initializer_list< T > list) noexcept |
| |
| bool | resizeWithoutInitializing (size_t newSize) noexcept |
| | Re-allocates to the requested new size, preserving its contents.
|
| |
| bool | resize (size_t newSize, const T &value=T()) noexcept |
| | Re-allocates to the requested new size, preserving its contents and setting new items to value.
|
| |
| bool | reserve (size_t capacity) noexcept |
| | Reserves capacity to avoid heap-allocation during a future append, assign or resize.
|
| |
| template<typename U = T> |
| bool | append (Span< const U > span) noexcept |
| | Appends a Span of items convertible to T to the end of the segment.
|
| |
| template<typename VTable2 > |
| bool | appendMove (Segment< VTable2 > &&other) noexcept |
| | Moves contents of another segment to the end of this segment.
|
| |
| bool | shrink_to_fit () noexcept |
| | Ensures capacity == size re-allocating (if capacity>size) or freeing ( if size==0) memory.
|
| |
| void | clear () noexcept |
| | Sets size to zero without freeing any memory (use shrink_to_fit() to free memory)
|
| |
| template<typename U = T> |
| bool | assign (Span< const U > span) noexcept |
| | Replaces contents with contents of the span.
|
| |
| template<typename VTable2 > |
| bool | assignMove (Segment< VTable2 > &&other) noexcept |
| | Replaces content moving (possibly "stealing") content of another segment.
|
| |
| bool | push_back (const T &value) noexcept |
| | Appends a single element to the end of the segment.
|
| |
| bool | push_back (T &&value) noexcept |
| | Moves a single element to the end of the segment.
|
| |
| bool | push_front (const T &value) noexcept |
| | Appends a single element to the start of the segment.
|
| |
| bool | pop_back (T *removedValue=nullptr) noexcept |
| | Removes the last element of the segment.
|
| |
| bool | pop_front (T *removedValue=nullptr) noexcept |
| | Removes the first element of the segment.
|
| |
|
T * | begin () noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
const T * | begin () const noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
T * | end () noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
const T * | end () const noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
T & | back () noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
T & | front () noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
const T & | back () const noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
const T & | front () const noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
T & | operator[] (size_t idx) noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
|
const T & | operator[] (size_t idx) const noexcept SC_LANGUAGE_LIFETIME_BOUND |
| |
| bool | isEmpty () const noexcept |
| | Check if is empty (size() == 0)
|
| |
| Span< T > | toSpan () noexcept SC_LANGUAGE_LIFETIME_BOUND |
| | Obtains a Span of internal contents.
|
| |
| Span< const T > | toSpanConst () const noexcept SC_LANGUAGE_LIFETIME_BOUND |
| | Obtains a Span of internal contents.
|
| |
| size_t | size () const noexcept |
| | Returns current size.
|
| |
| size_t | capacity () const noexcept |
| | Returns current capacity (always >= of size())
|
| |
| bool | removeRange (size_t start, size_t length) noexcept |
| | Removes the range [start, start + length] from the segment.
|
| |
| bool | removeAt (size_t index) noexcept |
| | Removes the element at index.
|
| |
| bool | insert (size_t index, Span< const T > data) noexcept |
| | Insert a span at the given index.
|
| |
template<typename VTable>
struct SC::Segment< VTable >
A slice of contiguous memory, prefixed by and header containing size and capacity.
Can act as a simple byte buffer or more of a "vector-like" class depending on the passed in VTable traits. It transparently handles going to and from an inline buffer (defined in derived classes) and the heap.
- Template Parameters
-
| VTable | provides copy / move / destruct operations (see SC::SegmentTrivial as an example) |
- Note
- Implementation is in
.inl to reduce include bloat for non-templated derived classes like SC::Buffer. This reduces header bloat as the .inl can be included where derived class is defined (typically a .cpp file).