Chromium Code Reviews| Index: net/base/priority_queue.h |
| =================================================================== |
| --- net/base/priority_queue.h (revision 218288) |
| +++ net/base/priority_queue.h (working copy) |
| @@ -139,6 +139,24 @@ |
| #endif |
| } |
| + // Adds |value| with |priority| to the queue. Returns a pointer to the |
| + // created element. |
| + Pointer InsertAtFront(const T& value, Priority priority) { |
| + DCHECK(CalledOnValidThread()); |
| + DCHECK_LT(priority, lists_.size()); |
| + ++size_; |
| + List& list = lists_[priority]; |
| +#if !defined(NDEBUG) |
| + unsigned id = next_id_; |
| + valid_ids_.insert(id); |
| + ++next_id_; |
| + return Pointer(priority, list.insert(list.begin(), |
| + std::make_pair(id, value))); |
| +#else |
| + return Pointer(priority, list.insert(list.begin(), value)); |
| +#endif |
| + } |
| + |
| // Removes the value pointed by |pointer| from the queue. All pointers to this |
| // value including |pointer| become invalid. |
| void Erase(const Pointer& pointer) { |
| @@ -213,6 +231,9 @@ |
| size_ = 0u; |
| } |
| + // Returns the number of priorities the queue supports. |
| + size_t NumPriorities() const { return lists_.size(); } |
|
szym
2013/08/20 16:24:57
nit: num_priorities
mmenke
2013/08/20 16:33:13
Done. I would have considered size() complicated
|
| + |
| // Returns number of queued values. |
| size_t size() const { |
| DCHECK(CalledOnValidThread()); |