5 #ifndef V8_COMPILER_FUNCTIONAL_LIST_H_ 6 #define V8_COMPILER_FUNCTIONAL_LIST_H_ 8 #include "src/zone/zone.h" 23 Cons(A top, Cons* rest)
24 : top(std::move(top)), rest(rest), size(1 + (rest ? rest->size : 0)) {}
34 if (Size() != other.Size())
return false;
38 if (it == other_it)
return true;
39 if (*it != *other_it)
return false;
45 return !(*
this == other);
48 const A& Front()
const {
50 return elements_->top;
61 elements_ = elements_->rest;
64 void PushFront(A a,
Zone* zone) {
65 elements_ =
new (zone) Cons(std::move(a), elements_);
71 if (hint.Size() == Size() + 1 && hint.Front() == a &&
72 hint.Rest() == *
this) {
83 while (other.Size() > Size()) other.DropFront();
84 while (other.Size() < Size()) DropFront();
85 while (elements_ != other.elements_) {
91 size_t Size()
const {
return elements_ ? elements_->size : 0; }
95 explicit iterator(Cons* cur) : current_(cur) {}
97 const A& operator*()
const {
return current_->top; }
99 current_ = current_->rest;
102 bool operator==(
const iterator& other)
const {
103 return this->current_ == other.current_;
105 bool operator!=(
const iterator& other)
const {
return !(*
this == other); }
112 iterator end()
const {
return iterator(
nullptr); }
122 #endif // V8_COMPILER_FUNCTIONAL_LIST_H_