|
Open Model Railroad Network (OpenMRN)
|
An mostly std::set<> compatible class that stores the internal data in a sorted vector. More...
#include <SortedListMap.hxx>
Public Types | |
| typedef D | data_type |
| Type of data stored in the set. | |
| typedef container_type::iterator | iterator |
| Iterator type. | |
| typedef container_type::const_iterator | const_iterator |
| Const Iterator type. | |
Public Member Functions | |
| template<typename... Args> | |
| SortedListSet (Args &&...args) | |
| void | reserve (size_t sz) |
| Ensures that a given size can be reached without memory allocation. | |
| iterator | begin () |
| iterator | end () |
| size_t | size () |
| template<class key_type > | |
| iterator | lower_bound (key_type key) |
| template<class key_type > | |
| iterator | upper_bound (key_type key) |
| template<class key_type > | |
| iterator | find (key_type key) |
| Searches for a single entry. | |
| template<class key_type > | |
| std::pair< iterator, iterator > | equal_range (key_type key) |
| void | insert (data_type &&d) |
| Adds new entry to the vector. | |
| void | erase (const iterator &it) |
| Removes an entry from the vector, pointed by an iterator. | |
| void | erase (const iterator &it_b, const iterator &it_e) |
| Removes a sequence of entries from the vector, pointed by a pair of iterators. | |
| void | clear () |
| Removes all entries. | |
Private Types | |
| typedef std::vector< data_type > | container_type |
| Type that we store data in internally. | |
Private Member Functions | |
| void | lazy_init () |
| Reestablishes sorted order in case anything was inserted or removed. | |
Private Attributes | |
| container_type | container_ |
| Holds the actual data elements. | |
| CMP | cmp_ |
| Comparator instance. | |
| size_t | sortedCount_ {0} |
| The first this many elements in the container are already sorted. | |
An mostly std::set<> compatible class that stores the internal data in a sorted vector.
Has low memory overhead; insertion cost is pretty high and lookup cost is logarithmic. Useful when a few insertions happen (for example only during initialization) and then lots of lookups are made.
Definition at line 46 of file SortedListMap.hxx.
| typedef container_type::const_iterator SortedListSet< D, CMP >::const_iterator |
Const Iterator type.
Definition at line 60 of file SortedListMap.hxx.
|
private |
Type that we store data in internally.
Definition at line 54 of file SortedListMap.hxx.
| typedef D SortedListSet< D, CMP >::data_type |
Type of data stored in the set.
Definition at line 50 of file SortedListMap.hxx.
| typedef container_type::iterator SortedListSet< D, CMP >::iterator |
Iterator type.
Definition at line 58 of file SortedListMap.hxx.
|
inline |
Definition at line 63 of file SortedListMap.hxx.
|
inline |
Definition at line 76 of file SortedListMap.hxx.
|
inline |
Removes all entries.
Definition at line 155 of file SortedListMap.hxx.
|
inline |
Definition at line 83 of file SortedListMap.hxx.
|
inline |
| key | what to search for |
Definition at line 125 of file SortedListMap.hxx.
|
inline |
Removes an entry from the vector, pointed by an iterator.
Definition at line 139 of file SortedListMap.hxx.
|
inline |
Removes a sequence of entries from the vector, pointed by a pair of iterators.
Definition at line 148 of file SortedListMap.hxx.
|
inline |
Searches for a single entry.
| key | is what to search for. |
Definition at line 114 of file SortedListMap.hxx.
|
inline |
Adds new entry to the vector.
Definition at line 133 of file SortedListMap.hxx.
|
inlineprivate |
Reestablishes sorted order in case anything was inserted or removed.
Definition at line 163 of file SortedListMap.hxx.
|
inline |
| key | what to search for |
Definition at line 95 of file SortedListMap.hxx.
|
inline |
Ensures that a given size can be reached without memory allocation.
| sz | the number of entries to prepare for. |
Definition at line 70 of file SortedListMap.hxx.
|
inline |
Definition at line 89 of file SortedListMap.hxx.
|
inline |
| key | what to search for |
Definition at line 104 of file SortedListMap.hxx.
|
private |
Comparator instance.
Definition at line 176 of file SortedListMap.hxx.
|
private |
Holds the actual data elements.
Definition at line 173 of file SortedListMap.hxx.
|
private |
The first this many elements in the container are already sorted.
Definition at line 179 of file SortedListMap.hxx.