Read-only array that either owns its elements or reads them from borrowed storage.
More...
|
| void | borrow (const void *owner, std::ptrdiff_t count, T(*read)(const void *, std::size_t)) |
| | View external storage instead of the owned elements, which are left unchanged.
|
| |
| std::ptrdiff_t | size () const |
| | Borrowed count while borrowing, otherwise the owned element count.
|
| |
| bool | isEmpty () const |
| | Return true when size() is 0.
|
| |
| T | operator[] (std::size_t i) const |
| | Element i, from the borrowed storage or the owned elements.
|
| |
| Iterator | begin () const |
| | Iterator at index 0.
|
| |
| Iterator | end () const |
| | Iterator at index size().
|
| |
| | Vector ()=default |
| | Empty vector.
|
| |
| | Vector (const std::vector< T > &v) |
| | Copy the elements of a std::vector.
|
| |
| | Vector (std::vector< T > &&v) |
| | Take over the buffer of a std::vector without copying elements.
|
| |
| decltype(auto) | first () |
| | Reference to the first element (front()); the vector must not be empty.
|
| |
| decltype(auto) | first () const |
| | Read-only reference to the first element; the vector must not be empty.
|
| |
| decltype(auto) | last () |
| | Reference to the last element (back()); the vector must not be empty.
|
| |
| decltype(auto) | last () const |
| | Read-only reference to the last element; the vector must not be empty.
|
| |
| const T * | constData () const |
| | Read-only pointer to the contiguous elements (data()).
|
| |
| Vector | mid (std::ptrdiff_t at, std::ptrdiff_t count=-1) const |
| | Copy of a contiguous run of elements.
|
| |
| void | prepend (const T &v) |
| | Insert a copy of v before the first element; linear in size().
|
| |
| void | append (const Vector &v) |
| | Append copies of all elements of v.
|
| |
| Vector & | operator+= (const Vector &v) |
| | Append copies of all elements of v; same as append(const Vector &).
|
| |
| Vector & | operator<< (const T &v) |
| | Append one element.
|
| |
| std::ptrdiff_t | size () const noexcept |
| | Number of elements as a signed std::ptrdiff_t.
|
| |
| bool | isEmpty () const |
| | True when the vector holds no elements.
|
| |
| void | append (const T &v) |
| | Append a copy of v (push_back).
|
| |
| void | append (T &&v) |
| | Append v by move (push_back).
|
| |
| T | takeLast () |
| | Remove the last element and return it by move; the vector must not be empty.
|
| |
| T | takeFirst () |
| | Remove the first element and return it by move; linear in size().
|
| |
| void | removeLast () |
| | Remove the last element (pop_back); the vector must not be empty.
|
| |
| void | removeAt (int at) |
| | Erase one element; the elements after it shift down by one.
|
| |
| void | fill (const T &v) |
| | Assign v to every existing element; the size is unchanged.
|
| |
| void | fill (const T &v, std::size_t size) |
| | Replace the contents with size copies of v (assign()).
|
| |
| bool | contains (const T &v) const |
| | Linear search with operator==.
|
| |
template<class T>
class meshkit::plan::ReadArray< T >
Read-only array that either owns its elements or reads them from borrowed storage.
Until borrow() is given a non-null owner, size(), operator[] and iteration use the owned Vector<T> elements. After borrow() they report the borrowed count instead and fetch each element by value through the supplied read function, so a container of another element type can be viewed without copying it. Members inherited from Vector<T> (first(), data(), append(), ...) always act on the owned elements, as does any access through a Vector<T> reference, because size() and operator[] hide rather than override the base members.
- Template Parameters
-
| T | Element type, returned by value. |