|
constexpr | ShortArray ()=default |
| Constructs a new empty array. More...
|
|
constexpr | ShortArray (const ShortArray &)=default |
| Constructs a new copy of the given array. More...
|
|
ShortArray & | operator= (const ShortArray &)=default |
| Sets this to be a copy of the given array. More...
|
|
constexpr bool | empty () const |
| Determines if this array is currently empty. More...
|
|
constexpr size_t | size () const |
| Returns the number of elements currently in this array. More...
|
|
constexpr size_t | max_size () const |
| Returns the maximum number of elements that can be held by this array. More...
|
|
T & | operator[] (size_t index) |
| Gives write access to the array element at the given index. More...
|
|
constexpr const T & | operator[] (size_t index) const |
| Gives read-only access to the array element at the given index. More...
|
|
constexpr const T & | front () const |
| Returns the first element in the array. More...
|
|
constexpr const T & | back () const |
| Returns the last element in the array. More...
|
|
iterator | begin () |
| Returns a read-write iterator pointing to the beginning of this array. More...
|
|
const_iterator | begin () const |
| Returns a read-only iterator pointing to the beginning of this array. More...
|
|
iterator | end () |
| Returns a read-write iterator pointing past the end of this array. More...
|
|
const_iterator | end () const |
| Returns a read-only iterator pointing past the end of this array. More...
|
|
void | push_back (const T &item) |
| Pushes a copy of the given item onto the end of this array. More...
|
|
void | push_back (T &&item) |
| Moves the given item onto the end of this array. More...
|
|
void | pop_back () |
| Removes the last item from this array. More...
|
|
void | clear () |
| Removes all elements from this array. More...
|
|
template<typename T, size_t maxSize>
class regina::ShortArray< T, maxSize >
A short stack-based array of bounded size.
ShortArray represents a stack-based array whose size is bounded above by the compile-time constant maxSize, but whose size at runtime can vary between 0 and maxSize inclusive.
Here "stack-based" means that the array does not use dynamic memory allocation; instead it reserves space for maxSize elements directly on the stack. In this sense, it is analogous to std::array<T, maxSize> or indeed a plain C-style array T[maxSize]. Like these other types, it is fast to access with very little space or time overhead, but it cannot be moved or swapped in constant time.
Where ShortArray differs from these other types is that its size can vary at runtime. Its default constructor initialises it to size zero, and it supports push_back() and pop_back() operations and a size() query which are all very fast. The size is, however, limited to maxSize, and any attempt to push additional elements beyond this limit will result in undefined behaviour.
This class was designed with very small arrays in mind; an example is the list of embeddings for a (dim-1)-dimensional face in a dim-dimensional triangulationw, which always has size 1 or 2.
This class does not implement move constructors or move assignment, since this cannot be done any faster than a linear-time copy operation. For the same reason, it does not implement its own custom swap functions.
- Python
- Not present.