OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
VectorOverArray< ItemType, SizeType > Class Template Reference

#include <OnixS/CME/MDH/VectorOverArray.h>

Public Types

using Item = ItemType
using Size = SizeType
using ConstIterator = const Item*
using Iterator = Item*

Public Member Functions

 VectorOverArray () noexcept=default
 VectorOverArray (Item *items, Size capacity) noexcept
 ~VectorOverArray () noexcept
bool empty () const noexcept
Size size () const noexcept
Size capacity () const noexcept
Iterator begin () noexcept
ConstIterator begin () const noexcept
Iterator end () noexcept
ConstIterator end () const noexcept
Item & front () noexcept
const Item & front () const noexcept
Item & operator[] (Size index) noexcept
const Item & operator[] (Size index) const noexcept
Item & at (Size index)
const Item & at (Size index) const
Item & insertExtrude (Size index) noexcept
void erase (Size index) noexcept
void clear () noexcept
void resize (Size newSize)
void resize (Size newSize, const Item &item)

Detailed Description

template<typename ItemType, typename SizeType>
class OnixS::CME::MDH::VectorOverArray< ItemType, SizeType >

The container manages the lifetime of its active items, but never allocates or deallocates the backing storage. The storage must be contiguous, suitably aligned, and remain valid for the entire lifetime of the container.

The active range [begin(), end()) is owned exclusively by this container: it constructs and destroys those items. A slot outside the active range may contain a pre-existing Item only when its lifetime may be ended without invoking its destructor and the storage owner will not subsequently invoke that destructor. Consequently, an ordinary Item array whose elements will later be destroyed by its owner is not suitable backing storage. Raw storage and storage containing trivially destructible placeholder items are suitable.

Template Parameters
ItemTypeStored item type. Instantiating the class requires this type to be nothrow destructible. Operations impose additional requirements: one-argument resize() requires default and copy construction; two-argument resize() requires copy construction; insertExtrude() requires nothrow copy construction; and erase() requires nothrow move construction.
SizeTypeType used for sizes, capacities, and indices. Instantiating the class requires an unsigned integral type.
Note
The container is neither copyable nor movable because it refers to externally owned storage.

Definition at line 67 of file VectorOverArray.h.

Member Typedef Documentation

◆ ConstIterator

template<typename ItemType, typename SizeType>
using ConstIterator = const Item*

Read-only random-access iterator type.

Definition at line 83 of file VectorOverArray.h.

◆ Item

template<typename ItemType, typename SizeType>
using Item = ItemType

Type of the stored items.

Definition at line 77 of file VectorOverArray.h.

◆ Iterator

template<typename ItemType, typename SizeType>
using Iterator = Item*

Mutable random-access iterator type.

Definition at line 86 of file VectorOverArray.h.

◆ Size

template<typename ItemType, typename SizeType>
using Size = SizeType

Type used for sizes, capacities, and indices.

Definition at line 80 of file VectorOverArray.h.

Constructor & Destructor Documentation

◆ VectorOverArray() [1/2]

template<typename ItemType, typename SizeType>
VectorOverArray ( )
defaultnoexcept

Creates an empty container without backing storage.

Note
Both the capacity and size are zero until destruction; storage cannot be attached later.

◆ VectorOverArray() [2/2]

template<typename ItemType, typename SizeType>
VectorOverArray ( Item * items,
Size capacity )
inlinenoexcept

Creates an empty container over caller-owned storage.

Parameters
itemsBeginning of storage suitable for capacity items.
capacityMaximum number of items that can be active.
Note
items may be null only when capacity is zero. The caller retains ownership of the storage and must keep it valid until this object is destroyed. Any pre-existing items in the storage must satisfy the lifetime requirements documented for the class.

Definition at line 100 of file VectorOverArray.h.

◆ ~VectorOverArray()

template<typename ItemType, typename SizeType>
~VectorOverArray ( )
inlinenoexcept

Destroys all active items without deallocating the backing storage.

Definition at line 108 of file VectorOverArray.h.

Member Function Documentation

◆ at() [1/2]

template<typename ItemType, typename SizeType>
Item & at ( Size index)
inline

Accesses an active item with bounds checking.

Parameters
indexZero-based index of the item.
Returns
Mutable reference to the requested item.
Exceptions
std::out_of_rangeIf index is not less than size().

Definition at line 224 of file VectorOverArray.h.

◆ at() [2/2]

template<typename ItemType, typename SizeType>
const Item & at ( Size index) const
inline

Accesses an active item with bounds checking.

Parameters
indexZero-based index of the item.
Returns
Read-only reference to the requested item.
Exceptions
std::out_of_rangeIf index is not less than size().

Definition at line 237 of file VectorOverArray.h.

◆ begin() [1/2]

template<typename ItemType, typename SizeType>
ConstIterator begin ( ) const
inlinenoexcept

Obtains a read-only iterator to the first item.

Returns
Beginning of the active range, or the backing-storage pointer when empty.

Definition at line 148 of file VectorOverArray.h.

◆ begin() [2/2]

template<typename ItemType, typename SizeType>
Iterator begin ( )
inlinenoexcept

Obtains a mutable iterator to the first item.

Returns
Beginning of the active range, or the backing-storage pointer when empty.

Definition at line 140 of file VectorOverArray.h.

◆ capacity()

template<typename ItemType, typename SizeType>
Size capacity ( ) const
inlinenoexcept

Obtains the maximum number of items supported by the backing storage.

Returns
Fixed container capacity.

Definition at line 132 of file VectorOverArray.h.

◆ clear()

template<typename ItemType, typename SizeType>
void clear ( )
inlinenoexcept

Destroys all active items.

Note
All iterators and references to active items, including the previous past-the-end iterator, are invalidated.

Definition at line 311 of file VectorOverArray.h.

◆ empty()

template<typename ItemType, typename SizeType>
bool empty ( ) const
inlinenoexcept

Checks whether the container has no active items.

Returns
true when the size is zero; otherwise false.

Definition at line 116 of file VectorOverArray.h.

◆ end() [1/2]

template<typename ItemType, typename SizeType>
ConstIterator end ( ) const
inlinenoexcept

Obtains a read-only iterator past the last active item.

Returns
End of the active range; null for an empty null-backed container.

Definition at line 164 of file VectorOverArray.h.

◆ end() [2/2]

template<typename ItemType, typename SizeType>
Iterator end ( )
inlinenoexcept

Obtains a mutable iterator past the last active item.

Returns
End of the active range; null for an empty null-backed container.

Definition at line 156 of file VectorOverArray.h.

◆ erase()

template<typename ItemType, typename SizeType>
void erase ( Size index)
inlinenoexcept

Erases an item and shifts subsequent items toward the beginning.

Parameters
indexZero-based index of the item to erase.
Note
The container must not be empty and index must be less than size(). These preconditions are asserted in assertion-enabled builds.
Iterators and references at or after index, including the previous past-the-end iterator, are invalidated.

Definition at line 282 of file VectorOverArray.h.

◆ front() [1/2]

template<typename ItemType, typename SizeType>
const Item & front ( ) const
inlinenoexcept

Accesses the first active item.

Returns
Read-only reference to the first item.
Note
The container must not be empty. This precondition is asserted in assertion-enabled builds.

Definition at line 186 of file VectorOverArray.h.

◆ front() [2/2]

template<typename ItemType, typename SizeType>
Item & front ( )
inlinenoexcept

Accesses the first active item.

Returns
Mutable reference to the first item.
Note
The container must not be empty. This precondition is asserted in assertion-enabled builds.

Definition at line 174 of file VectorOverArray.h.

◆ insertExtrude()

template<typename ItemType, typename SizeType>
Item & insertExtrude ( Size index)
inlinenoexcept

Opens a position by shifting subsequent items toward the end.

Parameters
indexZero-based position to open.
Returns
Mutable reference to the opened position, which retains the value previously stored at index.
Note
The size remains unchanged and the former last item is discarded. The returned item should be updated with the value being inserted.
The container must not be empty and index must be less than size(). These preconditions are asserted in assertion-enabled builds.
Treat iterators and references at or after index as invalidated. The returned reference designates the opened position.

Definition at line 255 of file VectorOverArray.h.

◆ operator[]() [1/2]

template<typename ItemType, typename SizeType>
const Item & operator[] ( Size index) const
inlinenoexcept

Accesses an active item without runtime bounds checking.

Parameters
indexZero-based index of the item.
Returns
Read-only reference to the requested item.
Note
index must be less than size(). This precondition is asserted in assertion-enabled builds.

Definition at line 212 of file VectorOverArray.h.

◆ operator[]() [2/2]

template<typename ItemType, typename SizeType>
Item & operator[] ( Size index)
inlinenoexcept

Accesses an active item without runtime bounds checking.

Parameters
indexZero-based index of the item.
Returns
Mutable reference to the requested item.
Note
index must be less than size(). This precondition is asserted in assertion-enabled builds.

Definition at line 199 of file VectorOverArray.h.

◆ resize() [1/2]

template<typename ItemType, typename SizeType>
void resize ( Size newSize)
inline

Changes the number of active items within the fixed capacity.

Parameters
newSizeRequested number of active items.
Exceptions
Anyexception thrown while default-constructing the value used for growth or copy-constructing a new item.
Note
newSize must not exceed capacity(). This precondition is asserted in assertion-enabled builds.
If construction fails while growing, already constructed items remain active and size() reflects them.
Growing preserves iterators and references to existing items but invalidates the previous past-the-end iterator. Shrinking invalidates iterators and references to removed items and the previous past-the-end iterator.

Definition at line 328 of file VectorOverArray.h.

◆ resize() [2/2]

template<typename ItemType, typename SizeType>
void resize ( Size newSize,
const Item & item )
inline

Changes the number of active items within the fixed capacity.

Parameters
newSizeRequested number of active items.
itemValue copied into each newly activated position when growing.
Exceptions
Anyexception thrown while copy-constructing a new item.
Note
newSize must not exceed capacity(). This precondition is asserted in assertion-enabled builds.
If construction fails while growing, already constructed items remain active and size() reflects them.
Growing preserves iterators and references to existing items but invalidates the previous past-the-end iterator. Shrinking invalidates iterators and references to removed items and the previous past-the-end iterator.

Definition at line 353 of file VectorOverArray.h.

◆ size()

template<typename ItemType, typename SizeType>
Size size ( ) const
inlinenoexcept

Obtains the number of active items.

Returns
Current number of items.

Definition at line 124 of file VectorOverArray.h.