21 #ifndef PAGESPEED_KERNEL_BASE_INLINE_SLIST_H_
22 #define PAGESPEED_KERNEL_BASE_INLINE_SLIST_H_
26 #include "base/logging.h"
29 namespace net_instaweb {
45 T* next() {
return next_; }
46 void set_next(T* new_next) { next_ = new_next; }
81 : list_(list), node_(node) {
85 return (node_ == NULL);
90 node_ = node_->next();
93 if (node_ == list_->tail_) {
102 bool Equals(
const IterBase& other)
const {
103 return (node_ == other.node_) && (list_ == other.list_);
107 friend class InlineSList<T>;
108 const InlineSList<T>* list_;
141 T* Get() {
return this->Data(); }
142 T* operator->() {
return this->Data(); }
143 T& operator*() {
return *this->Data(); }
144 bool operator==(
const Iterator& other)
const {
return this->Equals(other); }
145 bool operator!=(
const Iterator& other)
const {
146 return !this->Equals(other);
155 typedef Iterator iterator;
166 const T* Get() {
return this->Data(); }
167 const T* operator->() {
return this->Data(); }
168 const T& operator*() {
return *this->Data(); }
170 return this->Equals(other);
173 return !this->Equals(other);
182 typedef ConstIterator const_iterator;
190 bool IsEmpty()
const {
191 return (tail_ == NULL);
194 void Append(T* node);
201 void Erase(Iterator* iter);
209 const T*
Last()
const {
218 iterator
begin() {
return Iterator(
this, tail_); }
219 const_iterator
begin()
const {
return ConstIterator(
this, tail_); }
222 iterator
end() {
return Iterator(
this, NULL); }
223 const_iterator
end()
const {
return ConstIterator(
this, NULL); }
237 T* node = tail_->next();
239 T* next = node->next();
255 node->set_next(node);
257 node->set_next(tail_->next());
258 tail_->set_next(node);
265 DCHECK(!iter->AtEnd());
267 T* iter_node = iter->node_;
268 T* target_node = iter_node->next();
270 if (iter_node == target_node) {
275 iter_node->set_next(target_node->next());
276 if (target_node == tail_) {
T * Last()
Returns last item.
Definition: inline_slist.h:204
Definition: inline_slist.h:33
Definition: inline_slist.h:39
~InlineSList()
The destructor deletes all the nodes in the list.
Definition: inline_slist.h:235
void Erase(Iterator *iter)
Definition: inline_slist.h:264
iterator begin()
Iterator interface.
Definition: inline_slist.h:218
Definition: inline_slist.h:134
iterator end()
End iterators have their position at NULL.
Definition: inline_slist.h:222
Definition: inline_slist.h:159