FastLED 3.9.15
Loading...
Searching...
No Matches

◆ insert() [1/4]

template<typename Key, typename Less = fl::less<Key>>
fl::pair< iterator, bool > fl::flat_set< Key, Less >::insert ( const value_type & value)
inline

Definition at line 204 of file flat_set.h.

204 {
205 auto it = lower_bound(value);
206 if (it != end() && !mLess(value, *it) && !mLess(*it, value)) {
207 return fl::pair<iterator, bool>(it, false); // Already exists
208 }
209 bool success = mData.insert(it, value);
210 if (success) {
211 // After insert, find the newly inserted element
212 it = find(value);
213 return fl::pair<iterator, bool>(it, true);
214 }
215 return fl::pair<iterator, bool>(end(), false);
216 }
vector_type mData
Definition flat_set.h:44
iterator end()
Definition flat_set.h:76
iterator find(const Key &key)
Definition flat_set.h:94
iterator lower_bound(const Key &key)
Definition flat_set.h:119

References end(), find(), lower_bound(), mData, mLess, and fl::type_rank< T >::value.

Referenced by emplace(), emplace_hint(), insert(), and insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: