MTC
Public Types | Public Member Functions | Protected Attributes | List of all members
ordered< T, Compare > Class Template Reference

ordered<ValueType> provides an adapter for a std::list to allow sorting. More...

#include <cost_queue.h>

Public Types

using container_type = std::list< T >
 
using value_type = typename container_type::value_type
 
using size_type = typename container_type::size_type
 
using difference_type = typename container_type::difference_type
 
using reference = typename container_type::reference
 
using const_reference = typename container_type::const_reference
 
using pointer = typename container_type::pointer
 
using const_pointer = typename container_type::const_pointer
 
using iterator = typename container_type::iterator
 
using const_iterator = typename container_type::const_iterator
 
using reverse_iterator = typename container_type::reverse_iterator
 
using const_reverse_iterator = typename container_type::const_reverse_iterator
 

Public Member Functions

 ordered ()
 initialize empty container
 
bool empty () const
 
size_type size () const
 
void clear ()
 
reference top ()
 
const_reference top () const
 
value_type pop ()
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
void sort ()
 explicitly sort container, useful if many items have changed their value
 
iterator insert (const value_type &item)
 
iterator insert (value_type &&item)
 
void push (const value_type &item)
 
void push (value_type &&item)
 
iterator erase (const_iterator pos)
 
iterator update (iterator &it)
 update sort position of a single item after changes
 
iterator moveTo (iterator pos, container_type &other, iterator other_pos)
 move element pos from this to other container, inserting before other_pos
 
iterator moveFrom (iterator pos, container_type &other)
 move element pos from other container into this one (sorted)
 
template<typename Predicate >
void remove_if (Predicate p)
 

Protected Attributes

container_type c
 
Compare comp
 

Detailed Description

template<typename T, typename Compare = ValueOrPointeeLess<T>>
class ordered< T, Compare >

ordered<ValueType> provides an adapter for a std::list to allow sorting.

In contrast to std::priority_queue, we use a std::list as the underlying container. This ensures, that existing iterators remain valid upon insertion and deletion. Sorted insertion has logarithmic complexity.


The documentation for this class was generated from the following file: