|
| Lopmap () |
|
| Lopmap (std::initializer_list< std::pair< Key, T > > list) |
|
iterator | begin () |
|
const_iterator | begin () const |
|
const_iterator | cbegin () const |
|
const_iterator | cend () const |
|
void | clear () |
|
const_iterator | constBegin () const |
|
const_iterator | constEnd () const |
|
const_iterator | constFind (const Key &key) const |
|
const_reverse_iterator | constReverseBegin () const |
|
const_reverse_iterator | constReverseEnd () const |
|
bool | contains (const Key &key) const |
|
qsizetype | count () const |
|
const_reverse_iterator | crbegin () const |
|
const_reverse_iterator | crend () const |
|
bool | empty () const |
|
iterator | end () |
|
const_iterator | end () const |
|
std::pair< iterator, iterator > | equal_range (const T &value) |
|
std::pair< const_iterator, const_iterator > | equal_range (const T &value) const |
|
iterator | erase (const_iterator first, const_iterator last) |
|
iterator | erase (const_iterator pos) |
|
iterator | find (const Key &key) |
|
const_iterator | find (const Key &key) const |
|
const T & | first () const |
|
const Key & | firstKey () const |
|
iterator | insert (const Key &key, const T &value) |
|
void | insert (const Lopmap &other) |
|
iterator | insert (const_iterator pos, const Key &key, const T &value) |
|
void | insert (Lopmap &&other) |
|
bool | isEmpty () const |
|
Key | key (const T &value, const Key &defaultKey=Key()) const |
|
QList< Key > | keys () const |
|
QList< Key > | keys (const T &value) const |
|
const T & | last () const |
|
const Key & | lastKey () const |
|
iterator | lowerBound (const T &value) |
|
const_iterator | lowerBound (const T &value) const |
|
bool | operator!= (const Lopmap &other) const =default |
|
bool | operator== (const Lopmap &other) const |
|
T | operator[] (const Key &key) const |
|
reverse_iterator | rbegin () |
|
const_reverse_iterator | rbegin () const |
|
size_type | remove (const Key &key) |
|
template<typename Predicate>
requires lopmap_predicate<Key, T, Compare, Predicate> |
qsizetype | removeIf (Predicate pred) |
|
reverse_iterator | rend () |
|
const_reverse_iterator | rend () const |
|
qsizetype | size () const |
|
void | swap (Lopmap< Key, T > &other) |
|
T | take (const Key &key) |
|
iterator | upperBound (const T &value) |
|
const_iterator | upperBound (const T &value) const |
|
T | value (const Key &key, const T &defaultValue=T()) const |
|
QList< T > | values () const |
|
template<typename Key, typename T, typename Compare>
requires std::predicate<Compare, T, T>
class Qx::Lopmap< Key, T, Compare >
Qx::Lopmap<Key, T, Compare> is like QMap<Key, T>, except that values in the map are sorted by value instead of key, with an order dictated by Compare.
Unlike QMap, iterator is simply an alias for const_iterator as values cannot be modified through lopmap iterators since that would affect ordering. Additionally, some methods that would traditional take Key as an argument, instead take T.
The value type of Lopmap must provide operator<(), or a custom Compare object must be provided specifying a total order.
template<typename Key, typename T, typename Compare>
Inserts a new item with the key key and value of value.
If there is already an item with the key key, that item's value is replaced with value.
Returns an iterator pointing to the new/updated element.
template<typename Key, typename T, typename Compare>
Inserts a new item with the key key and value value and with hint pos suggesting where to do the insert.
If constBegin() is used as hint it indicates that the value should come before any value in the map while constEnd() suggests that the value should (strictly) come after any key in the map. Otherwise, the hint should meet the condition (pos - 1).value() < value <= pos.value() (assuming a Comapre of std::less<Value>). If the hint pos is wrong it is ignored and a regular insert is done.
If there is already an item with the key key, that item's value is replaced with value.
If the hint is correct, the insert executes in amortized constant time.
When creating a map from sorted data inserting the last value first with constBegin() is faster than inserting in sorted order with constEnd(), since constEnd() - 1 (which is needed to check if the hint is valid) needs logarithmic time.
Returns an iterator pointing to the new/updated element.
template<typename Key, typename T, typename Compare>
Key Qx::Lopmap< Key, T, Compare >::key |
( |
const T & | value, |
|
|
const Key & | defaultKey = Key() ) const |
|
inline |
Returns the key with value value, or defaultKey if the lopmap contains no item with value. If no defaultKey is provided the functionr returns a default-constructed key.
This function can be slow, because Lopmap's internal data structure is optimized for fast lookup by key, not by value.
- See also
- value(), and keys().
template<typename Key, typename T, typename Compare>
Returns true
if other is not equal to this lopmap; otherwise, returns false
.
Two lopmap's are considered equal if they contain the same (key, value) pairs.
This function requires the key and the value types to implement operator==()
.
- See also
- operator==().
template<typename Key, typename T, typename Compare>
bool Qx::Lopmap< Key, T, Compare >::operator== |
( |
const Lopmap< Key, T, Compare > & | other | ) |
const |
|
inline |
Returns true
if other is equal to this lopmap; otherwise, returns false
.
Two lopmap's are considered equal if they contain the same (key, value) pairs.
This function requires the key and the value types to implement operator==()
.
- See also
- operator!=().
template<typename Key, typename T, typename Compare>
template<typename Predicate>
requires lopmap_predicate<Key, T, Compare, Predicate>
qsizetype Qx::Lopmap< Key, T, Compare >::removeIf |
( |
Predicate | pred | ) |
|
|
inline |
Removes all elements for which the predicate pred returns true from the lopmap.
The function supports predicates which take either an argument of type Lopmap<Key, T, Compare>::const_iterator, or an argument of type std::pair<const Key&, const T&>.
Returns the number of elements removed, if any.
- See also
- clear() and take().
template<typename Key, typename T, typename Compare>
T Qx::Lopmap< Key, T, Compare >::take |
( |
const Key & | key | ) |
|
|
inline |
Removes the item with the key key from the lopmap and returns the value associated with it.
If this item does not exist in the lopmap, the function simply returns a default-constructed value
If you don't use the return value, remove() is more efficient.
- See also
- remove().