template<class T>
class roc::core::Slice< T >
Slice.
Slice points to a subrange of data in pool-allocated Buffer. Copying a slice produces a new slice referring the same data.
Slice also acts as a kind of shared pointer to Buffer. A buffer won't be freed (returned to pool) until there are slices referring it. Copying a slice increments the buffer reference counter, and destroying a slice decrements it.
While Buffer works with raw bytes, Slice<T> interprets it as array of elements of type T, and works in terms of those elements.
Slice has two important characteristics:
- size - the difference between the ending end beginning pointer
- capacity - the difference between the actual buffer end and the slice beginning pointer
Buffers are not resizable. They're allocated from pool and have fixed size, defined by the pool parameters.
Slices are reslicable, which means that their pointers to the buffer data may be moved within the buffer.
The beginning pointer may be moved only forward. Once moved, it's not allowed to move it backward again. Moving it decreases the slice size and capacity. Capacity is affected because it's relative to the beginning pointer.
The ending pointer may be freely moved forward and backward within the slice capacity. Moving it affects the slice size, but not capacity.
In other words, slice capacity may be only decreased by moving beginning pointer, and slice size may be freely changed within the slice capacity by moving both beginning and ending pointers.
Definition at line 55 of file slice.h.