24template <
typename Key,
typename Value, fl::size N>
class FixedMap {
41 for (
auto it =
begin(); it !=
end(); ++it) {
42 if (it->first == key) {
50 for (
auto it =
begin(); it !=
end(); ++it) {
51 if (it->first == key) {
68 template <
typename Less>
89 template <
typename Less>
102 bool get(
const Key &key, Value *value)
const {
135 if (
data.size() < N) {
141 return {
true,
data.end() - 1};
147 return {
false,
end()};
160 if (
data.size() < N) {
165 return {
true,
data.end() - 1};
170 return {
false,
end()};
174 bool insert_if_missing =
true) {
179 }
else if (insert_if_missing) {
180 return insert(key, value).first;
187 bool insert_if_missing =
true) {
192 }
else if (insert_if_missing) {
204 return data.back().second;
212 static Value default_value;
213 return default_value;
217 bool allow_rollover =
false)
const {
222 *next_key = it->first;
224 }
else if (allow_rollover && !
empty()) {
225 *next_key =
begin()->first;
233 bool allow_rollover =
false)
const {
238 *prev_key = it->first;
240 }
else if (allow_rollover && !
empty()) {
241 *prev_key =
data[
data.size() - 1].first;
249 constexpr fl::size
size()
const {
return data.size(); }
269template <
typename Key,
typename Value,
typename Less = fl::less<Key>>
301 return comp_(
x.first,
y.first);
341 FASTLED_ASSERT(ok,
"Failed to insert into SortedHeapMap");
347 FASTLED_ASSERT(it !=
end(),
"SortedHeapMap::at: key not found");
351 const Value &
at(
const Key &key)
const {
353 FASTLED_ASSERT(it !=
end(),
"SortedHeapMap::at: key not found");
384 template<
class... Args>
404 return data.erase(it);
454 if (it !=
end() && it->first == key) {
462 if (it !=
end() && it->first == key) {
484 if (!
insert(key, value)) {
499 bool get(
const Key &key, Value *value)
const {
515 if (it->first != other_it->first ||
516 it->second != other_it->second) {
524 return !(*
this == other);
539template <
typename Key,
typename T,
typename Compare = fl::less<Key>>
bool contains(const Key &key) const
constexpr fl::size size() const
VectorType::iterator iterator
const_iterator begin() const
bool prev(const Key &key, Key *prev_key, bool allow_rollover=false) const
iterator lowest(Less less_than=Less())
pair< bool, iterator > insert(Key &&key, Value &&value, InsertResult *result=nullptr)
bool has(const int &it) const
pair< bool, iterator > insert(const Key &key, const Value &value, InsertResult *result=nullptr)
fl::pair< Key, Value > PairKV
Value & operator[](const Key &key)
bool update(const Key &key, Value &&value, bool insert_if_missing=true)
const_iterator lowest(Less less_than=Less()) const
const_iterator highest(Less less_than=Less()) const
iterator find(const Key &key)
bool next(const Key &key, Key *next_key, bool allow_rollover=false) const
const_iterator find(const Key &key) const
iterator highest(Less less_than=Less())
bool update(const Key &key, const Value &value, bool insert_if_missing=true)
const Value & operator[](const Key &key) const
constexpr bool empty() const
Value get(const Key &key, bool *has=nullptr) const
FixedVector< PairKV, N > VectorType
VectorType::const_iterator const_iterator
constexpr FixedMap()=default
bool get(const Key &key, Value *value) const
constexpr fl::size capacity() const
const_iterator end() const
const PairKV * const_iterator
bool operator()(const value_type &x, const value_type &y) const
friend class SortedHeapMap
void update(const Key &key, Value &&value)
iterator upper_bound(const Key &key)
const value_type * const_pointer
const_iterator begin() const
const_iterator end() const
void update(const Key &key, const Value &value)
value_compare value_comp() const
bool has(const Key &key) const
fl::pair< iterator, bool > insert(value_type &&value)
void swap(SortedHeapMap &other)
ptrdiff_t difference_type
const value_type & const_reference
const_iterator lower_bound(const Key &key) const
const value_type & back() const
SortedHeapMap(Less less=Less())
fl::size count(const Key &key) const
const value_type & front() const
fl::pair< iterator, bool > insert(const value_type &value)
bool contains(const Key &key) const
iterator lower_bound(const Key &key)
bool operator!=(const SortedHeapMap &other) const
fl::pair< const_iterator, const_iterator > equal_range(const Key &key) const
SortedHeapVector< value_type, PairLess >::iterator iterator
fl::size capacity() const
fl::pair< Key, Value > value_type
key_compare key_comp() const
bool get(const Key &key, Value *value) const
fl::size erase(const Key &key)
const_iterator upper_bound(const Key &key) const
SortedHeapVector< value_type, PairLess > data
bool insert(const Key &key, const Value &value, InsertResult *result=nullptr)
bool insert(Key &&key, Value &&value, InsertResult *result=nullptr)
SortedHeapMap(const SortedHeapMap &other)=default
Value & operator[](const Key &key)
const_iterator find(const Key &key) const
iterator find(const Key &key)
const_iterator cbegin() const
const_iterator cend() const
void setMaxSize(fl::size n)
Value & at(const Key &key)
fl::size max_size() const
SortedHeapVector< value_type, PairLess >::const_iterator const_iterator
bool operator==(const SortedHeapMap &other) const
const Value & at(const Key &key) const
fl::pair< iterator, iterator > equal_range(const Key &key)
SortedHeapMap & operator=(const SortedHeapMap &other)=default
iterator erase(const_iterator pos)
fl::pair< iterator, bool > emplace(Args &&... args)
HeapVector< T >::const_iterator const_iterator
HeapVector< T >::iterator iterator
Result type for promise operations.
Implements the FastLED namespace macros.
constexpr remove_reference< T >::type && move(T &&t) noexcept
__PTRDIFF_TYPE__ ptrdiff_t
MapRedBlackTree< Key, T, Compare, fl::allocator_slab< char > > fl_map
constexpr T && forward(typename remove_reference< T >::type &t) noexcept
bool operator()(const value_type &a, const value_type &b) const
Binary function object that returns whether the first argument is less than the second.