Qx v0.6
Qt Extensions Library
|
The Lopmap class is a template class that provides an "lopsided" associative array. More...
#include <qx/core/qx-lopmap.h>
Classes | |
class | const_iterator |
The Lopmap::const_iterator class provides an STL-style const iterator for Lopmap. More... | |
class | const_reverse_iterator |
The Lopmap::const_reverse_iterator class provides an STL-style const reverse iterator for Lopmap. More... | |
Public Types | |
using | ConstIterator = const_iterator |
using | ConstReverseIterator = const_reverse_iterator |
using | difference_type = typename StorageContainer::difference_type |
using | iterator = const_iterator |
using | Iterator = iterator |
using | key_type = Key |
using | mapped_Type = T |
using | reverse_iterator = const_reverse_iterator |
using | ReverseIterator = reverse_iterator |
using | size_type = typename StorageContainer::size_type |
using | value_compare = Compare |
Public Member Functions | |
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 |
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.
Qx::Lopmap< Key, T, Compare >::ConstIterator = const_iterator |
Qt-style synonym for Lopmap::const_iterator.
Qx::Lopmap< Key, T, Compare >::ConstReverseIterator = const_reverse_iterator |
Qt-style synonym for const_reverse_iterator.
Qx::Lopmap< Key, T, Compare >::difference_type = typename StorageContainer::difference_type |
Typedef for the container's difference type, usually std::ptrdiff_t.
Qx::Lopmap< Key, T, Compare >::iterator = const_iterator |
Typedef for const_iterator.
Qx::Lopmap< Key, T, Compare >::Iterator = iterator |
Qt-style synonym for Lopmap::iterator.
Qx::Lopmap< Key, T, Compare >::key_type = Key |
Typedef for Key.
Qx::Lopmap< Key, T, Compare >::mapped_Type = T |
Typedef for T.
Qx::Lopmap< Key, T, Compare >::reverse_iterator = const_reverse_iterator |
Typedef for const_reverse_iterator.
Qx::Lopmap< Key, T, Compare >::ReverseIterator = reverse_iterator |
Qt-style synonym for reverse_iterator.
Qx::Lopmap< Key, T, Compare >::size_type = typename StorageContainer::size_type |
Typedef for the container's size_type, usually std::size_t.
Qx::Lopmap< Key, T, Compare >::value_compare = Compare |
Typedef for Compare.
|
inline |
Creates an empty lopmap.
|
inline |
Creates a lopmap with a copy of each of the elements in the initializer list list.
|
inline |
Same as constBegin().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Same as constBegin().
|
inline |
Same as constEnd().
|
inline |
Removes all items from the lopmap.
|
inline |
Returns an STL-style iterator pointing to the first item in the lopmap.
|
inline |
Returns an STL-style iterator pointing to the imaginary item after the last item in the lopmap.
|
inline |
Returns an iterator pointing to the item with the key key in the lopmap.
If the lopmaps contains no item with the key key, the function returns constEnd().
|
inline |
Returns an STL-style iterator pointing to the last item in the lopmap.
|
inline |
Returns an STL-style iterator pointing to the imaginary item after the first item in the lopmap.
|
inline |
Returns true
if the lopmap contains an item with the key key; otherwise, returns false
.
|
inline |
Same as size().
|
inline |
Same as constReverseBegin().
|
inline |
Same as constReverseEnd().
|
inline |
Same as isEmpty().
|
inline |
Same as constEnd().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Returns a pair of iterators delimiting the range of values [first, second), that are stored with value.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
|
inline |
|
inline |
Same as constFind().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Returns a reference to the first value in the lopmap.
This function assumes that the map is not empty.
|
inline |
|
inline |
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.
|
inline |
Inserts all the items in the other lopmap into this lopmap.
If a key is common to both maps, its value with be replaced with the value stored in other.
|
inline |
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.
|
inline |
Moves all the items from other into this lopmap.
If a key is common to both maps, its value with be replaced with the value stored in other.
|
inline |
Returns true
if the lopmap contains no items; otherwise, returns false
.
|
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.
|
inline |
|
inline |
Returns a list containing all of the keys associated with the value value in order of their associated values.
This function creates a new list, in linear time.
|
inline |
Returns a reference to the last value in the lopmap.
This function assumes that the map is not empty.
|
inline |
|
inline |
Returns an iterator pointing to the first item with value value in the lopmap. If the map contains no item with value value, the function returns an iterator to the nearest item with a greater value, or constEnd() if there is none.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
default |
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==()
.
|
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==()
.
|
inline |
Same as value().
|
inline |
Same as constReverseBegin().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
|
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.
|
inline |
Same as constReverseEnd().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
|
inline |
Swaps lopmap other with this lopmap. This operation is very fast and never fails.
|
inline |
|
inline |
Returns an iterator pointing to the item that immediately follows the last item with value value in the lopmap. If the map contains no item with value value, the function returns an iterator to the nearest item with a greater value, or constEnd() if there is none.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Returns the value associated with the key key.
If the lopmap contains no item with key key, the function returns defaultValue. If no defaultValue is specified, the function returns a default-constructed value.
|
inline |