Index: base/containers/linked_list.h |
diff --git a/base/containers/linked_list.h b/base/containers/linked_list.h |
index 25bbe762cb759b4eba6c67b00ec0206c3e6bec4f..41461ff365e66fdbd568e2dcd3a96b7d212378ae 100644 |
--- a/base/containers/linked_list.h |
+++ b/base/containers/linked_list.h |
@@ -5,6 +5,8 @@ |
#ifndef BASE_CONTAINERS_LINKED_LIST_H_ |
#define BASE_CONTAINERS_LINKED_LIST_H_ |
+#include "base/macros.h" |
+ |
// Simple LinkedList type. (See the Q&A section to understand how this |
// differs from std::list). |
// |
@@ -82,7 +84,7 @@ namespace base { |
template <typename T> |
class LinkNode { |
public: |
- LinkNode() : previous_(0), next_(0) {} |
+ LinkNode() : previous_(NULL), next_(NULL) {} |
LinkNode(LinkNode<T>* previous, LinkNode<T>* next) |
: previous_(previous), next_(next) {} |
@@ -106,6 +108,10 @@ class LinkNode { |
void RemoveFromList() { |
this->previous_->next_ = this->next_; |
this->next_->previous_ = this->previous_; |
+ // next() and previous() return non-NULL if and only this node is not in any |
+ // list. |
+ this->next_ = NULL; |
+ this->previous_ = NULL; |
} |
LinkNode<T>* previous() const { |
@@ -128,6 +134,8 @@ class LinkNode { |
private: |
LinkNode<T>* previous_; |
LinkNode<T>* next_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LinkNode); |
}; |
template <typename T> |
@@ -155,8 +163,12 @@ class LinkedList { |
return &root_; |
} |
+ bool empty() const { return head() == end(); } |
+ |
private: |
LinkNode<T> root_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LinkedList); |
}; |
} // namespace base |