OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
TinyStrSet Class Reference

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

Public Types

using Item = Messaging::StrRef
using ConstIterator = TinyStrSetIterator

Public Member Functions

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

Detailed Description

Unlike TinySet<Messaging::StrRef>, this class copies the referenced characters into owned strings. Lookup is linear, and iteration follows insertion order.

Note
Views returned by iterators remain valid only while their strings remain unmodified and stored in this set. Insertion can invalidate every iterator and view; erasure invalidates those at and after the erased string.

Definition at line 435 of file TinySet.h.

Member Typedef Documentation

◆ ConstIterator

Read-only iterator over owned strings.

Definition at line 442 of file TinySet.h.

◆ Item

Non-owning string view accepted and returned by the set.

Definition at line 439 of file TinySet.h.

Constructor & Destructor Documentation

◆ TinyStrSet() [1/4]

TinyStrSet ( )
default

Constructs an empty string set.

◆ TinyStrSet() [2/4]

TinyStrSet ( size_t capacity)
inlineexplicit

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

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

Definition at line 452 of file TinySet.h.

◆ TinyStrSet() [3/4]

TinyStrSet ( const TinyStrSet & other)
default

Constructs a deep copy of another string set.

Parameters
otherString set to copy.
Exceptions
std::bad_allocIf storage or string allocation fails.

◆ TinyStrSet() [4/4]

TinyStrSet ( TinyStrSet && other)
default

Constructs a string set by transferring another set's storage.

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

◆ ~TinyStrSet()

~TinyStrSet ( )
default

Releases all owned string storage.

Member Function Documentation

◆ begin()

ConstIterator begin ( ) const
inline

Returns an iterator to the first owned string.

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

Definition at line 536 of file TinySet.h.

◆ clear()

void clear ( )
inlinenoexcept

Removes all strings without reducing reserved capacity.

Note
Invalidates all iterators and returned views.

Definition at line 600 of file TinySet.h.

◆ empty()

bool empty ( ) const
inlinenoexcept

Checks whether the set contains no strings.

Returns
true if the set is empty; otherwise false.

Definition at line 507 of file TinySet.h.

◆ end()

ConstIterator end ( ) const
inline

Returns the past-the-end iterator.

Returns
Iterator following the last owned string.

Definition at line 545 of file TinySet.h.

◆ erase()

bool erase ( Item item)
inlinenoexcept

Removes the string whose characters equal the supplied view.

Parameters
itemString view to match.
Returns
true if a string was removed; false if no matching string exists.
Note
Iterators and views at and after the erased string are invalidated.

Definition at line 585 of file TinySet.h.

◆ find()

ConstIterator find ( Item item) const
inline

Finds a string whose characters equal the supplied view.

Parameters
itemString view to locate.
Returns
Iterator to the matching string, or end() when no match exists.

Definition at line 555 of file TinySet.h.

◆ insert()

bool insert ( Item item)
inline

Copies a string into the set unless equal content is already present.

Parameters
itemView of the characters to copy.
Returns
true if the string was inserted; false if equal content already exists.
Exceptions
std::length_errorIf the string or resulting set exceeds its maximum supported size.
std::bad_allocIf string or storage allocation fails.
Note
The set does not retain item or depend on its lifetime after this call. Successful insertion can invalidate all iterators and returned views.

Definition at line 568 of file TinySet.h.

◆ operator=() [1/2]

TinyStrSet & operator= ( const TinyStrSet & other)
inline

Replaces the content with a deep copy of another string set.

Parameters
otherString set to copy.
Returns
This string set.
Exceptions
std::bad_allocIf storage or string allocation fails.
Note
If copying fails, this set remains unchanged.

Definition at line 475 of file TinySet.h.

◆ operator=() [2/2]

TinyStrSet & operator= ( TinyStrSet && other)
inlinenoexcept

Replaces the content by transferring another set's storage.

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

Definition at line 492 of file TinySet.h.

◆ reserve()

void reserve ( size_t capacity)
inline

Reserves storage for at least the requested number of strings.

Parameters
capacityNumber of strings for which to reserve storage.
Exceptions
std::length_errorIf capacity exceeds the maximum supported size.
std::bad_allocIf storage allocation fails.
Note
Reallocation invalidates all iterators and returned views.

Definition at line 527 of file TinySet.h.

◆ size()

size_t size ( ) const
inlinenoexcept

Returns the number of stored strings.

Returns
Number of strings in the set.

Definition at line 516 of file TinySet.h.

◆ swap()

void swap ( TinyStrSet & other)
inlinenoexcept

Exchanges owned strings and capacity with another set.

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

Definition at line 610 of file TinySet.h.