47 class IsTinySetKeyNothrowEqualityComparable
49 template <
class Cand
idate>
50 static auto test(
int) -> std::integral_constant
51 <bool,
noexcept(
static_cast<bool>(std::declval<const Candidate&>() == std::declval<const Candidate&>()))>;
53 template <
class>
static std::false_type test(...);
56 static constexpr bool value =
decltype(test<Key>(0))::value;
59 static_assert(std::is_copy_constructible<Key>::value,
"Key must be copy-constructible");
60 static_assert(std::is_nothrow_move_assignable<Key>::value,
"Key must be nothrow move-assignable");
61 static_assert(std::is_nothrow_destructible<Key>::value,
"Key must be nothrow destructible");
62 static_assert(IsTinySetKeyNothrowEqualityComparable::value,
"Key must be nothrow equality-comparable");
69 using Items = std::vector<Item>;
109 if ONIXS_CMEMDH_LIKELY(&other !=
this)
126 if ONIXS_CMEMDH_LIKELY(&other !=
this)
127 items_ = std::move(other.items_);
141 return items_.empty();
150 return items_.size();
162 items_.reserve(capacity);
171 return items_.begin();
190 return std::find(items_.begin(), items_.end(), item);
205 items_.push_back(item);
220 const auto found =
find(item);
222 if (items_.end() == found)
245 items_.swap(other.items_);
272 using Items = std::vector<std::string>;
350 : iterator_(iterator)
385 return iterator_ == other.iterator_;
396 return iterator_ != other.iterator_;
424 ItemIterator iterator_;
477 if ONIXS_CMEMDH_LIKELY(&other !=
this)
494 if ONIXS_CMEMDH_LIKELY(&other !=
this)
495 items_ = std::move(other.items_);
509 return items_.empty();
518 return items_.size();
529 items_.reserve(capacity);
557 return ConstIterator(std::find_if(items_.begin(), items_.end(), ItemLocator(item)));
587 const auto found = std::find_if(items_.begin(), items_.end(), ItemLocator(item));
589 if (items_.end() == found)
612 items_.swap(other.items_);
616 using Items = std::vector<std::string>;
628 bool operator()(
const std::string& other)
const noexcept
630 return sought_ == other;
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_LTWT
#define ONIXS_CMEMDH_NAMESPACE_END
#define ONIXS_CMEMDH_NODISCARD
Stores a small number of unique keys in contiguous storage.
void reserve(size_t capacity)
void clear() noexcept
Removes all keys without reducing reserved capacity.
bool erase(const Item &item) noexcept
Removes the key equal to the requested value.
TinySet(TinySet &&other)=default
Constructs a set by transferring another set's storage.
TinySet(const TinySet &other)=default
Constructs a set containing copies of another set's keys.
TinySet(size_t capacity)
Constructs an empty set with storage reserved for at least the requested capacity.
std::vector< Item > Items
typename Items::const_iterator ConstIterator
size_t size() const noexcept
Returns the number of stored keys.
bool empty() const noexcept
Checks whether the set contains no keys.
ConstIterator find(const Item &item) const noexcept
Finds a key equal to the requested value.
ConstIterator begin() const noexcept
Returns an iterator to the first stored key.
~TinySet()=default
Releases the owned key storage.
TinySet()=default
Constructs an empty set.
bool insert(const Item &item)
Inserts a copy of a key unless an equal key is already present.
TinySet & operator=(TinySet &&other) noexcept
Replaces the stored keys by transferring another set's storage.
ConstIterator end() const noexcept
Returns the past-the-end iterator.
TinySet & operator=(const TinySet &other)
Replaces the stored keys with copies of another set's keys.
void swap(TinySet &other) noexcept
Proxy providing pointer-like access to a dereferenced string view.
const value_type * operator->() const noexcept
Returns a pointer to the proxied string view.
Pointer(value_type value) noexcept
Constructs a proxy for a string view.
Provides read-only iteration over strings owned by TinyStrSet.
TinyStrSetIterator operator++(int)
Advances to the next string while retaining the previous position.
bool operator!=(const TinyStrSetIterator &other) const
Checks whether two iterators refer to different positions.
std::vector< std::string > Items
String storage type traversed by the iterator.
TinyStrSetIterator(const TinyStrSetIterator &other)=default
Constructs an iterator referring to the same position as another iterator.
TinyStrSetIterator & operator++()
Advances to the next string.
TinyStrSetIterator & operator=(const TinyStrSetIterator &other)=default
Makes this iterator refer to the same position as another iterator.
Messaging::StrRef value_type
Value produced when the iterator is dereferenced.
Messaging::StrRef operator*() const
Returns a non-owning view of the current string.
Items::const_iterator ItemIterator
Underlying iterator type.
~TinyStrSetIterator()=default
Destroys the iterator without affecting the underlying string.
TinyStrSetIterator()=default
Constructs a singular iterator.
bool operator==(const TinyStrSetIterator &other) const
Checks whether two iterators refer to the same position.
TinyStrSetIterator(const ItemIterator &iterator)
Wraps an iterator over TinyStrSet string storage.
std::input_iterator_tag iterator_category
Iterator category used by standard algorithms.
TinyStrSetIterator(TinyStrSetIterator &&other)=default
Constructs an iterator by moving another iterator.
TinyStrSetIterator & operator=(TinyStrSetIterator &&other)=default
Replaces this iterator's state by moving another iterator.
value_type reference
Type returned when the iterator is dereferenced.
typename std::iterator_traits< ItemIterator >::difference_type difference_type
Signed type used to represent distances between iterators.
Pointer pointer
Pointer-like proxy type returned by operator->().
pointer operator->() const
Provides pointer-like access to the current string view.
Stores unique strings supplied through non-owning Messaging::StrRef views.
void reserve(size_t capacity)
Reserves storage for at least the requested number of strings.
void clear() noexcept
Removes all strings without reducing reserved capacity.
Messaging::StrRef Item
Non-owning string view accepted and returned by the set.
size_t size() const noexcept
Returns the number of stored strings.
bool empty() const noexcept
Checks whether the set contains no strings.
TinyStrSet(size_t capacity)
Constructs an empty string set with storage reserved for at least the requested capacity.
TinyStrSetIterator ConstIterator
Read-only iterator over owned strings.
TinyStrSet(const TinyStrSet &other)=default
Constructs a deep copy of another string set.
ConstIterator end() const
Returns the past-the-end iterator.
TinyStrSet & operator=(TinyStrSet &&other) noexcept
Replaces the content by transferring another set's storage.
TinyStrSet()=default
Constructs an empty string set.
TinyStrSet & operator=(const TinyStrSet &other)
Replaces the content with a deep copy of another string set.
void swap(TinyStrSet &other) noexcept
Exchanges owned strings and capacity with another set.
~TinyStrSet()=default
Releases all owned string storage.
bool erase(Item item) noexcept
Removes the string whose characters equal the supplied view.
bool insert(Item item)
Copies a string into the set unless equal content is already present.
ConstIterator find(Item item) const
Finds a string whose characters equal the supplied view.
ConstIterator begin() const
Returns an iterator to the first owned string.
TinyStrSet(TinyStrSet &&other)=default
Constructs a string set by transferring another set's storage.
StrRef toStrRef(const std::string &str) noexcept
Constructs a StrRef instance over th std::string content.
std::basic_string_view< Char > StrRef
void toStr(std::string &, Int8)
Serializes given integer into a string.
void swap(TinySet< Key > &left, TinySet< Key > &right) noexcept
Exchanges the content and capacity of two sets.
MboBook & copy(MboBook &target, const MboBook &source)
Copies content of MBO book to the other one.