28template<
typename Key,
typename Value,
size_t N>
55 for (
auto it =
begin(); it !=
end(); ++it) {
56 if (it->first == key) {
64 for (
auto it =
begin(); it !=
end(); ++it) {
65 if (it->first == key) {
72 template<
typename Less>
83 template<
typename Less>
94 template<
typename Less>
105 template<
typename Less>
118 bool get(
const Key& key, Value* value)
const {
150 if (
data.size() < N) {
156 return {
true,
data.end() - 1};
162 return {
false,
end()};
165 bool update(
const Key& key,
const Value& value,
bool insert_if_missing =
true) {
170 }
else if (insert_if_missing) {
171 return insert(key, value).first;
182 return data.back().second;
190 static Value default_value;
191 return default_value;
194 bool next(
const Key& key,
Key* next_key,
bool allow_rollover =
false)
const {
199 *next_key = it->first;
201 }
else if (allow_rollover && !
empty()) {
202 *next_key =
begin()->first;
209 bool prev(
const Key& key,
Key* prev_key,
bool allow_rollover =
false)
const {
214 *prev_key = it->first;
216 }
else if (allow_rollover && !
empty()) {
217 *prev_key =
data[
data.size() - 1].first;
226 constexpr size_t size()
const {
256template <
typename Key,
typename Value,
typename Less = fl::DefaultLess<Key>>
283 :
data(PairLess{less}) {
295 return data.insert(Pair(key, value), result);
299 if (!
insert(key, value)) {
315 return data.has(Pair(key));
327 it !=
end(); ++it, ++other_it) {
328 if (it->first != other_it->first || it->second != other_it->second) {
336 return !(*
this == other);
352 return data.find(Pair(key));
355 return data.find(Pair(key));
359 return data.erase(Pair(key));
362 return data.erase(it);
366 return data.lower_bound(Pair(key));
370 return data.lower_bound(Pair(key));
375 if (it !=
end() && it->
first == key) {
383 if (it !=
end() && it->
first == key) {
400 Pair pair(key, Value());
401 bool ok =
data.insert(pair);
403 return data.find(pair)->second;
#define FASTLED_ASSERT(x, MSG)
bool contains(const Key &key) const
Pair< bool, iterator > insert(const Key &key, const Value &value, InsertResult *result=nullptr)
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())
bool has(const int &it) const
Value & operator[](const Key &key)
constexpr size_t size() const
const_iterator lowest(Less less_than=Less()) const
const_iterator highest(Less less_than=Less()) const
constexpr size_t capacity() 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
fl::Pair< Key, Value > PairKV
const_iterator end() const
const PairKV * const_iterator
iterator upper_bound(const Key &key)
const_iterator begin() const
const_iterator end() const
void update(const Key &key, const Value &value)
bool has(const Key &key) const
const Pair & back() const
bool erase(const Key &key)
void swap(SortedHeapMap &other)
const_iterator lower_bound(const Key &key) const
SortedHeapMap(Less less=Less())
SortedHeapVector< Pair, PairLess >::iterator iterator
bool contains(const Key &key) const
iterator lower_bound(const Key &key)
bool operator!=(const SortedHeapMap &other) const
const_iterator upper_bound(const Key &key) const
bool insert(const Key &key, const Value &value, InsertResult *result=nullptr)
Value & operator[](const Key &key)
const_iterator find(const Key &key) const
iterator find(const Key &key)
SortedHeapVector< Pair, PairLess > data
Value & at(const Key &key)
SortedHeapVector< Pair, PairLess >::const_iterator const_iterator
const Pair & front() const
bool operator==(const SortedHeapMap &other) const
void setMaxSize(size_t n)
HeapVector< T >::const_iterator const_iterator
HeapVector< T >::iterator iterator
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
bool operator()(const T &a, const T &b) const
Pair(const Key &k=Key(), const Value &v=Value())
bool operator()(const Pair &a, const Pair &b) const