| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 INLINE(explicit List(int capacity)) { Initialize(capacity); } | 50 INLINE(explicit List(int capacity)) { Initialize(capacity); } |
| 51 INLINE(~List()) { DeleteData(data_); } | 51 INLINE(~List()) { DeleteData(data_); } |
| 52 | 52 |
| 53 INLINE(void* operator new(size_t size)) { return P::New(size); } | 53 INLINE(void* operator new(size_t size)) { return P::New(size); } |
| 54 INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); } | 54 INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); } |
| 55 | 55 |
| 56 inline T& operator[](int i) const { | 56 inline T& operator[](int i) const { |
| 57 ASSERT(0 <= i && i < length_); | 57 ASSERT(0 <= i && i < length_); |
| 58 return data_[i]; | 58 return data_[i]; |
| 59 } | 59 } |
| 60 inline T& at(int i) const { return this->operator[](i); } | 60 inline T& at(int i) const { return operator[](i); } |
| 61 INLINE(const T& last() const) { | 61 inline T& last() const { |
| 62 ASSERT(!is_empty()); | 62 ASSERT(!is_empty()); |
| 63 return this->at(length_ - 1); | 63 return at(length_ - 1); |
| 64 } | 64 } |
| 65 | 65 |
| 66 INLINE(bool is_empty() const) { return length_ == 0; } | 66 INLINE(bool is_empty() const) { return length_ == 0; } |
| 67 INLINE(int length() const) { return length_; } | 67 INLINE(int length() const) { return length_; } |
| 68 | 68 |
| 69 Vector<T> ToVector() { return Vector<T>(data_, length_); } | 69 Vector<T> ToVector() { return Vector<T>(data_, length_); } |
| 70 | 70 |
| 71 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } | 71 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } |
| 72 | 72 |
| 73 // Adds a copy of the given 'element' to the end of the list, | 73 // Adds a copy of the given 'element' to the end of the list, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); } | 114 INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); } |
| 115 INLINE(void DeleteData(T* data)) { P::Delete(data); } | 115 INLINE(void DeleteData(T* data)) { P::Delete(data); } |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(List); | 117 DISALLOW_COPY_AND_ASSIGN(List); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 | 120 |
| 121 } } // namespace v8::internal | 121 } } // namespace v8::internal |
| 122 | 122 |
| 123 #endif // V8_LIST_H_ | 123 #endif // V8_LIST_H_ |
| OLD | NEW |