| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); } | 55 INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); } |
| 56 | 56 |
| 57 // Returns a reference to the element at index i. This reference is | 57 // Returns a reference to the element at index i. This reference is |
| 58 // not safe to use after operations that can change the list's | 58 // not safe to use after operations that can change the list's |
| 59 // backing store (eg, Add). | 59 // backing store (eg, Add). |
| 60 inline T& operator[](int i) const { | 60 inline T& operator[](int i) const { |
| 61 ASSERT(0 <= i && i < length_); | 61 ASSERT(0 <= i && i < length_); |
| 62 return data_[i]; | 62 return data_[i]; |
| 63 } | 63 } |
| 64 inline T& at(int i) const { return operator[](i); } | 64 inline T& at(int i) const { return operator[](i); } |
| 65 inline T& last() const { | 65 inline T& last() const { return at(length_ - 1); } |
| 66 return at(length_ - 1); | 66 inline T& first() const { return at(0); } |
| 67 } | |
| 68 | 67 |
| 69 INLINE(bool is_empty() const) { return length_ == 0; } | 68 INLINE(bool is_empty() const) { return length_ == 0; } |
| 70 INLINE(int length() const) { return length_; } | 69 INLINE(int length() const) { return length_; } |
| 71 INLINE(int capacity() const) { return capacity_; } | 70 INLINE(int capacity() const) { return capacity_; } |
| 72 | 71 |
| 73 Vector<T> ToVector() { return Vector<T>(data_, length_); } | 72 Vector<T> ToVector() { return Vector<T>(data_, length_); } |
| 74 | 73 |
| 75 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } | 74 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } |
| 76 | 75 |
| 77 // Adds a copy of the given 'element' to the end of the list, | 76 // Adds a copy of the given 'element' to the end of the list, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 139 |
| 141 // Add() is inlined, ResizeAdd() called by Add() is inlined except for | 140 // Add() is inlined, ResizeAdd() called by Add() is inlined except for |
| 142 // Lists of FrameElements, and ResizeAddInternal() is inlined in ResizeAdd(). | 141 // Lists of FrameElements, and ResizeAddInternal() is inlined in ResizeAdd(). |
| 143 template <> | 142 template <> |
| 144 void List<FrameElement, | 143 void List<FrameElement, |
| 145 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element); | 144 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element); |
| 146 | 145 |
| 147 } } // namespace v8::internal | 146 } } // namespace v8::internal |
| 148 | 147 |
| 149 #endif // V8_LIST_H_ | 148 #endif // V8_LIST_H_ |
| OLD | NEW |