16 bool operator()(
const T &a,
const T &b)
const {
return a < b; }
24template <
typename Key,
typename Value,
size_t 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 {
102 bool get(
const Key &key, Value *value)
const {
…}
135 if (
data.size() < N) {
141 return {
true,
data.end() - 1};
147 return {
false,
end()};
151 bool insert_if_missing =
true) {
156 }
else if (insert_if_missing) {
157 return insert(key, value).first;
168 return data.back().second;
176 static Value default_value;
177 return default_value;
181 bool allow_rollover =
false)
const {
186 *next_key = it->first;
188 }
else if (allow_rollover && !
empty()) {
189 *next_key =
begin()->first;
197 bool allow_rollover =
false)
const {
202 *prev_key = it->first;
204 }
else if (allow_rollover && !
empty()) {
205 *prev_key =
data[
data.size() - 1].first;
213 constexpr size_t size()
const {
return data.size(); }
24template <
typename Key,
typename Value,
size_t N>
class FixedMap {
…};
233template <
typename Key,
typename Value,
typename Less = fl::DefaultLess<Key>>
267 return data.insert(Pair(key, value), result);
271 if (!
insert(key, value)) {
285 bool get(
const Key &key, Value *value)
const {
285 bool get(
const Key &key, Value *value)
const {
…}
294 bool has(
const Key &key)
const {
return data.has(Pair(key)); }
304 if (it->first != other_it->first ||
305 it->second != other_it->second) {
313 return !(*
this == other);
337 return data.lower_bound(Pair(key));
342 if (it !=
end() && it->
first == key) {
350 if (it !=
end() && it->
first == key) {
366 Pair
pair(key, Value());
368 FASTLED_ASSERT(ok,
"Failed to insert into SortedHeapMap");
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
bool get(const Key &key, Value *value) 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
Binary function object that returns whether the first argument is less than the second.