Template that gives the programmer the functionality of FIFO. Strong exception safety, copy-on-write.
template <class K, class V>
class keyed_queue
K
must have no-argument default constructor, copy and move constructor and assignment operator, linear order
V
must have copy constructor
default constructor
- creates empty queueO(1)
copy constructor
- copy-on-writeO(1)
orO(n logn)
when copy is necessarymove constructor
- no-throwO(1)
desctructor
- no throwassignment operator
-O(1)
push(K const &k, V const &v)
- adds value to the end with specific keyO(log n)
in some cases time of copypop()
- removes first element, if empty throwslookup_error
O(log n)
in some cases time of copypop(K const &)
- removes first element with given keyK
O(log n)
in some cases time of copymove_to_back(K const &k)
- moves elements withK
key to the end of queue, preserves the orderO(log n)
in some cases time of copy where m is count(k)std::pair<K const &, V &> front()
- returns first element, pair: key and value, it's possible to change value but not keyO(1)
n some cases time of copystd::pair<K const &, V &> back()
- returns last element, pair: key and value, it's possible to change value but not keyO(1)
n some cases time of copystd::pair<K const &, V const &> front() const
- as above with costO(1)
std::pair<K const &, V const &> back() const
- as above with costO(1)
std::pair<K const &, V &> first(K const &key)
- returns first element with given key, pair: key and value, it's possible to change value but not keyO(1)
n some cases time of copy, if there is no such key, throwslookup_error
std::pair<K const &, V &> last(K const &key)
- returns last element with given key, pair: key and value, it's possible to change value but not keyO(1)
n some cases time of copy, if there is no such key, throwslookup_error
std::pair<K const &, V const &> first(K const &key) const
- as above with costO(1)
std::pair<K const &, V const &> last(K const &key) const
- as above with costO(1)
size_t size() const
- returns number of elements in queueO(1)
bool empty() const
- return true if queue is empty, otherwise falseO(1)
clear()
- removes all elements from queueO(n)
size_t count(K const &) const
- returns number of elements with given keyO(log n)
k_iterator k_begin()
- return iterator to the beginning of queuek_iterator k_end()
- returns iterator to the end of queue
default no-argument
andcopy constructor
++ operator
!=
and== operators
operator*
Created thanks toBoost.Operators
. Iterators are null when queue is successfully modified. Those objects provides read-only access in increasing order.
Project was made for classes at University of Warsaw.