OLD | NEW |
1 // Copyright 2006-2008 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 ASSERT(0 <= i && i < length_); | 60 ASSERT(0 <= i && i < length_); |
61 return data_[i]; | 61 return data_[i]; |
62 } | 62 } |
63 inline T& at(int i) const { return operator[](i); } | 63 inline T& at(int i) const { return operator[](i); } |
64 inline T& last() const { | 64 inline T& last() const { |
65 return at(length_ - 1); | 65 return at(length_ - 1); |
66 } | 66 } |
67 | 67 |
68 INLINE(bool is_empty() const) { return length_ == 0; } | 68 INLINE(bool is_empty() const) { return length_ == 0; } |
69 INLINE(int length() const) { return length_; } | 69 INLINE(int length() const) { return length_; } |
| 70 INLINE(int capacity() const) { return capacity_; } |
70 | 71 |
71 Vector<T> ToVector() { return Vector<T>(data_, length_); } | 72 Vector<T> ToVector() { return Vector<T>(data_, length_); } |
72 | 73 |
73 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } | 74 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } |
74 | 75 |
75 // 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, |
76 // expanding the list if necessary. | 77 // expanding the list if necessary. |
77 void Add(const T& element); | 78 void Add(const T& element); |
78 | 79 |
79 // Added 'count' elements with the value 'value' and returns a | 80 // Added 'count' elements with the value 'value' and returns a |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); } | 118 INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); } |
118 INLINE(void DeleteData(T* data)) { P::Delete(data); } | 119 INLINE(void DeleteData(T* data)) { P::Delete(data); } |
119 | 120 |
120 DISALLOW_COPY_AND_ASSIGN(List); | 121 DISALLOW_COPY_AND_ASSIGN(List); |
121 }; | 122 }; |
122 | 123 |
123 | 124 |
124 } } // namespace v8::internal | 125 } } // namespace v8::internal |
125 | 126 |
126 #endif // V8_LIST_H_ | 127 #endif // V8_LIST_H_ |
OLD | NEW |