|
Stratax 0.2.0
|
Version: v0.2.0
Status: Complete
Header: include/stratax/core/containers/Buffer.hpp
Buffer<T> is a fixed-size contiguous storage container.
It owns dynamically allocated memory, provides RAII semantics, and supplies iterator support for all higher-level Stratax containers. Buffer<T> serves as the foundation upon which Shape, Strides, Vector, Matrix, and Tensor are built.
The Buffer class is responsible for:
The Buffer class is not responsible for:
Depends on:
Used by:
Related classes:
| Member | Description |
|---|---|
| T* data_ | Pointer to contiguous memory owned by the buffer |
| std::size_t size_ | Number of stored elements |
The following conditions are always true:
Buffer<T> exposes iterator aliases for STL-style generic code. Other storage-related types such as pointers, references, and sizes remain spelled out in the public API.
Constructs an empty buffer that owns no storage.
Complexity
Throws
Constructs a buffer containing size default-initialized elements.
Complexity
Throws
Constructs a buffer containing size copies of value.
Complexity
Throws
Constructs a buffer from an initializer list.
Complexity
Throws
Constructs a deep copy of another buffer.
Complexity
Transfers ownership from another buffer.
Complexity
Releases owned memory.
Complexity
Performs a deep copy.
Complexity
Transfers ownership.
Complexity
Returns the first element of the buffer.
Preconditions
Complexity
See Also
Returns the last element of the buffer.
Preconditions
Complexity
See Also
Returns a pointer to the first stored element.
Complexity
See Also
Returns the number of stored elements.
Complexity
Returns true if the buffer contains no elements.
Complexity
Assigns every stored element the value value.
Preconditions
Postconditions
Complexity
Exchanges the contents of two buffers.
Complexity
Returns a reference to an element.
Bounds checking is not performed.
Complexity
See Also
| Operation | Complexity |
|---|---|
| Default construction | O(1) |
| Size construction | O(n) |
| Fill construction | O(n) |
| Initializer list construction | O(n) |
| Copy construction | O(n) |
| Move construction | O(1) |
| Copy assignment | O(n) |
| Move assignment | O(1) |
| Destruction | O(n) |
| Element access | O(1) |
| Iteration | O(n) |
| fill() | O(n) |
| swap() | O(1) |
Buffer<T> stores data in a single contiguous memory block.
Higher-level containers such as Matrix and Tensor interpret this one-dimensional storage using Shape and Strides. This design improves cache locality, simplifies memory management, and allows algorithms to operate on a consistent underlying representation.
Empty buffer iterators are valid sentinels: begin() == end() and reverse iterator pairs are also equal for an empty buffer.
Buffer<T> intentionally contains no mathematical logic. Its sole responsibility is memory ownership and element storage.