Chromium Code Reviews| Index: net/base/priority_queue.h |
| diff --git a/net/base/priority_queue.h b/net/base/priority_queue.h |
| index f60b88c69a05319958ae80eb97db603cda350484..bc8796c55a886f09ab477cd8371169fcced91eba 100644 |
| --- a/net/base/priority_queue.h |
| +++ b/net/base/priority_queue.h |
| @@ -34,7 +34,7 @@ class PriorityQueue : public base::NonThreadSafe { |
| private: |
| // This section is up-front for Pointer only. |
| #if !defined(NDEBUG) |
| - typedef std::list<std::pair<size_t, T> > List; |
| + typedef std::list<std::pair<unsigned, T> > List; |
| #else |
| typedef std::list<T> List; |
| #endif |
| @@ -49,10 +49,25 @@ class PriorityQueue : public base::NonThreadSafe { |
| // Constructs a null pointer. |
| Pointer() : priority_(kNullPriority) { |
| #if !defined(NDEBUG) |
| - id_ = static_cast<size_t>(-1); |
| + id_ = static_cast<unsigned>(-1); |
| #endif |
| } |
| + Pointer(const Pointer& p) : priority_(p.priority_), iterator_(p.iterator_) { |
| +#if !defined(NDEBUG) |
| + id_ = p.id_; |
| +#endif |
| + } |
| + |
| + Pointer& operator=(const Pointer& p) { |
| + priority_ = p.priority_; |
|
stevez
2012/05/30 17:12:45
You may want to check for self-assignment.
szym
2012/05/30 23:53:24
Self-assignment is benign. Added comment.
|
| + iterator_ = p.iterator_; |
| +#if !defined(NDEBUG) |
| + id_ = p.id_; |
| +#endif |
| + return *this; |
| + } |
| + |
| bool is_null() const { return priority_ == kNullPriority; } |
| Priority priority() const { return priority_; } |
| @@ -94,7 +109,7 @@ class PriorityQueue : public base::NonThreadSafe { |
| #if !defined(NDEBUG) |
| // Used by the queue to check if a Pointer is valid. |
| - size_t id_; |
| + unsigned id_; |
| #endif |
| }; |
| @@ -114,7 +129,7 @@ class PriorityQueue : public base::NonThreadSafe { |
| ++size_; |
| List& list = lists_[priority]; |
| #if !defined(NDEBUG) |
| - size_t id = next_id_; |
| + unsigned id = next_id_; |
| valid_ids_.insert(id); |
| ++next_id_; |
| return Pointer(priority, list.insert(list.end(), |
| @@ -208,15 +223,18 @@ class PriorityQueue : public base::NonThreadSafe { |
| typedef std::vector<List> ListVector; |
| #if !defined(NDEBUG) |
| - size_t next_id_; |
| - base::hash_set<size_t> valid_ids_; |
| + unsigned next_id_; |
| + base::hash_set<unsigned> valid_ids_; |
| #endif |
| ListVector lists_; |
| size_t size_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PriorityQueue); |
| }; |
| } // namespace net |
| #endif // NET_BASE_PRIORITY_QUEUE_H_ |
| + |