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

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

Public Types

using Item = Key
using Items = std::vector<Item>
using ConstIterator = typename Items::const_iterator

Public Member Functions

 TinySet ()=default
 TinySet (size_t capacity)
 TinySet (const TinySet &other)=default
 TinySet (TinySet &&other)=default
TinySet & operator= (const TinySet &other)
TinySet & operator= (TinySet &&other) noexcept
 ~TinySet ()=default
bool empty () const noexcept
size_t size () const noexcept
void reserve (size_t capacity)
ConstIterator begin () const noexcept
ConstIterator end () const noexcept
ConstIterator find (const Item &item) const noexcept
bool insert (const Item &item)
bool erase (const Item &item) noexcept
void clear () noexcept
void swap (TinySet &other) noexcept

Detailed Description

template<class Key>
class OnixS::CME::MDH::TinySet< Key >
Template Parameters
KeyCopy-constructible, nothrow move-assignable, nothrow destructible, and nothrow equality-comparable item type.
Note
Lookup is linear. Iteration follows insertion order rather than sorted order. Insertion can invalidate all iterators, while erasure invalidates iterators at and after the erased element.

Definition at line 45 of file TinySet.h.

Member Typedef Documentation

◆ ConstIterator

template<class Key>
using ConstIterator = typename Items::const_iterator

Read-only iterator over stored keys.

Definition at line 72 of file TinySet.h.

◆ Item

template<class Key>
using Item = Key

Key type stored by the set.

Definition at line 66 of file TinySet.h.

◆ Items

template<class Key>
using Items = std::vector<Item>

Contiguous storage type used by the set.

Definition at line 69 of file TinySet.h.

Constructor & Destructor Documentation

◆ TinySet() [1/4]

template<class Key>
TinySet ( )
default

Constructs an empty set.

◆ TinySet() [2/4]

template<class Key>
TinySet ( size_t capacity)
inlineexplicit

Constructs an empty set with storage reserved for at least the requested capacity.

Parameters
capacityNumber of keys for which to reserve storage.
Exceptions
std::length_errorIf capacity exceeds the maximum supported size.
std::bad_allocIf storage allocation fails.

Definition at line 82 of file TinySet.h.

◆ TinySet() [3/4]

template<class Key>
TinySet ( const TinySet< Key > & other)
default

Constructs a set containing copies of another set's keys.

Parameters
otherSet to copy.
Exceptions
std::bad_allocIf storage allocation fails.
Anyexception thrown by Item copy construction.

◆ TinySet() [4/4]

template<class Key>
TinySet ( TinySet< Key > && other)
default

Constructs a set by transferring another set's storage.

Parameters
otherSet whose content is transferred.
Note
After the operation, other remains valid but has unspecified content.

◆ ~TinySet()

template<class Key>
~TinySet ( )
default

Releases the owned key storage.

Member Function Documentation

◆ begin()

template<class Key>
ConstIterator begin ( ) const
inlinenoexcept

Returns an iterator to the first stored key.

Returns
Iterator to the first key, or end() if the set is empty.

Definition at line 169 of file TinySet.h.

◆ clear()

template<class Key>
void clear ( )
inlinenoexcept

Removes all keys without reducing reserved capacity.

Note
Invalidates all iterators.

Definition at line 233 of file TinySet.h.

◆ empty()

template<class Key>
bool empty ( ) const
inlinenoexcept

Checks whether the set contains no keys.

Returns
true if the set is empty; otherwise false.

Definition at line 139 of file TinySet.h.

◆ end()

template<class Key>
ConstIterator end ( ) const
inlinenoexcept

Returns the past-the-end iterator.

Returns
Iterator following the last stored key.

Definition at line 178 of file TinySet.h.

◆ erase()

template<class Key>
bool erase ( const Item & item)
inlinenoexcept

Removes the key equal to the requested value.

Parameters
itemKey to remove.
Returns
true if a key was removed; false if no matching key exists.
Note
Iterators at and after the erased key are invalidated.

Definition at line 218 of file TinySet.h.

◆ find()

template<class Key>
ConstIterator find ( const Item & item) const
inlinenoexcept

Finds a key equal to the requested value.

Parameters
itemKey to locate.
Returns
Iterator to the matching key, or end() when no match exists.

Definition at line 188 of file TinySet.h.

◆ insert()

template<class Key>
bool insert ( const Item & item)
inline

Inserts a copy of a key unless an equal key is already present.

Parameters
itemKey to insert.
Returns
true if the key was inserted; false if an equal key already exists.
Exceptions
std::length_errorIf growing the set would exceed its maximum supported size.
std::bad_allocIf storage allocation fails.
Anyexception thrown by Item copy construction.
Note
Successful insertion can invalidate all iterators.

Definition at line 201 of file TinySet.h.

◆ operator=() [1/2]

template<class Key>
TinySet & operator= ( const TinySet< Key > & other)
inline

Replaces the stored keys with copies of another set's keys.

Parameters
otherSet to copy.
Returns
This set.
Exceptions
std::bad_allocIf storage allocation fails.
Anyexception thrown by Item copy construction.
Note
If copying fails, this set remains unchanged.

Definition at line 107 of file TinySet.h.

◆ operator=() [2/2]

template<class Key>
TinySet & operator= ( TinySet< Key > && other)
inlinenoexcept

Replaces the stored keys by transferring another set's storage.

Parameters
otherSet whose content is transferred.
Returns
This set.
Note
After the operation, other remains valid but has unspecified content.

Definition at line 124 of file TinySet.h.

◆ reserve()

template<class Key>
void reserve ( size_t capacity)
inline

Reserves storage for at least the requested number of keys.

Parameters
capacityNumber of keys for which to reserve storage.
Exceptions
std::length_errorIf capacity exceeds the maximum supported size.
std::bad_allocIf storage allocation fails.
Anyexception thrown while relocating an Item.
Note
Reallocation invalidates all iterators.

Definition at line 160 of file TinySet.h.

◆ size()

template<class Key>
size_t size ( ) const
inlinenoexcept

Returns the number of stored keys.

Returns
Number of keys in the set.

Definition at line 148 of file TinySet.h.

◆ swap()

template<class Key>
void swap ( TinySet< Key > & other)
inlinenoexcept

Exchanges stored keys and capacity with another set.

Parameters
otherSet with which to exchange content.
Note
Iterators continue to refer to their elements, which belong to the opposite set after the operation. Past-the-end iterators can be invalidated.

Definition at line 243 of file TinySet.h.