13 #ifndef FOXXLL_COMMON_ADDRESSABLE_QUEUES_HEADER 14 #define FOXXLL_COMMON_ADDRESSABLE_QUEUES_HEADER 28 template <
typename KeyType>
33 using meta_type = std::map<KeyType, container_iterator>;
50 {
return vals.empty(); }
57 std::pair<handle, bool>
insert(
const KeyType& e)
60 std::pair<handle, bool> r = meta.insert(std::make_pair(e, ei));
64 vals.erase(r.first->second);
78 vals.erase(mi->second);
87 vals.erase(i->second);
93 const KeyType &
top()
const 94 {
return vals.front(); }
101 const KeyType e =
top();
112 template <
typename KeyType,
typename PriorityType,
class Cmp = std::less<PriorityType> >
117 bool operator () (
const std::pair<PriorityType, KeyType>& left,
118 const std::pair<PriorityType, KeyType>& right)
const 121 return c(left.first, right.first) ||
122 ((! c(right.first, left.first)) && left.second < right.second);
128 using meta_type = std::map<KeyType, container_iterator>;
145 {
return vals.empty(); }
151 std::pair<handle, bool>
insert(
const KeyType& e,
const PriorityType o)
153 std::pair<container_iterator, bool> s = vals.insert(std::make_pair(o, e));
154 std::pair<handle, bool> r = meta.insert(std::make_pair(e, s.first));
155 if (! r.second && s.second)
158 vals.erase(r.first->second);
159 r.first->second = s.first;
170 if (mi == meta.end())
172 vals.erase(mi->second);
181 vals.erase(i->second);
187 const KeyType &
top()
const 188 {
return vals.begin()->second; }
195 const KeyType e =
top();
197 vals.erase(vals.begin());
204 #endif // !FOXXLL_COMMON_ADDRESSABLE_QUEUES_HEADER
std::map< swappable_block_identifier_type, container_iterator > meta_type
bool erase(const KeyType &e)
meta_iterator handle
Type of handle to an entry. For use with insert and remove.
std::list< swappable_block_identifier_type > container_type
const KeyType & top() const
typename meta_type::iterator meta_iterator
std::pair< handle, bool > insert(const KeyType &e, const PriorityType o)
std::set< std::pair< foxxll::block_scheduler_algorithm_offline_lfd::priority, swappable_block_identifier_type >, cmp > container_type
~addressable_fifo_queue()
~addressable_priority_queue()
addressable_fifo_queue()
Create an empty queue.
const KeyType & top() const
typename meta_type::iterator meta_iterator
std::map< swappable_block_identifier_type, container_iterator > meta_type
typename container_type::iterator container_iterator
bool erase(const KeyType &e)
std::pair< handle, bool > insert(const KeyType &e)
typename container_type::iterator container_iterator
meta_iterator handle
Type of handle to an entry. For use with insert and remove.
addressable_priority_queue()
Create an empty queue.