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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return data_[i]; | 73 return data_[i]; |
74 } | 74 } |
75 inline T& at(int i) const { return operator[](i); } | 75 inline T& at(int i) const { return operator[](i); } |
76 inline T& last() const { return at(length_ - 1); } | 76 inline T& last() const { return at(length_ - 1); } |
77 inline T& first() const { return at(0); } | 77 inline T& first() const { return at(0); } |
78 | 78 |
79 INLINE(bool is_empty() const) { return length_ == 0; } | 79 INLINE(bool is_empty() const) { return length_ == 0; } |
80 INLINE(int length() const) { return length_; } | 80 INLINE(int length() const) { return length_; } |
81 INLINE(int capacity() const) { return capacity_; } | 81 INLINE(int capacity() const) { return capacity_; } |
82 | 82 |
83 Vector<T> ToVector() { return Vector<T>(data_, length_); } | 83 Vector<T> ToVector() const { return Vector<T>(data_, length_); } |
84 | 84 |
85 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } | 85 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } |
86 | 86 |
87 // Adds a copy of the given 'element' to the end of the list, | 87 // Adds a copy of the given 'element' to the end of the list, |
88 // expanding the list if necessary. | 88 // expanding the list if necessary. |
89 void Add(const T& element); | 89 void Add(const T& element); |
90 | 90 |
91 // Add all the elements from the argument list to this list. | 91 // Add all the elements from the argument list to this list. |
92 void AddAll(const List<T, P>& other); | 92 void AddAll(const List<T, P>& other); |
93 | 93 |
| 94 // Add all the elements from the vector to this list. |
| 95 void AddAll(const Vector<T>& other); |
| 96 |
94 // Inserts the element at the specific index. | 97 // Inserts the element at the specific index. |
95 void InsertAt(int index, const T& element); | 98 void InsertAt(int index, const T& element); |
96 | 99 |
97 // Added 'count' elements with the value 'value' and returns a | 100 // Added 'count' elements with the value 'value' and returns a |
98 // vector that allows access to the elements. The vector is valid | 101 // vector that allows access to the elements. The vector is valid |
99 // until the next change is made to this list. | 102 // until the next change is made to this list. |
100 Vector<T> AddBlock(T value, int count); | 103 Vector<T> AddBlock(T value, int count); |
101 | 104 |
102 // Removes the i'th element without deleting it even if T is a | 105 // Removes the i'th element without deleting it even if T is a |
103 // pointer type; moves all elements above i "down". Returns the | 106 // pointer type; moves all elements above i "down". Returns the |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 158 |
156 // Resize the list. | 159 // Resize the list. |
157 void Resize(int new_capacity); | 160 void Resize(int new_capacity); |
158 | 161 |
159 DISALLOW_COPY_AND_ASSIGN(List); | 162 DISALLOW_COPY_AND_ASSIGN(List); |
160 }; | 163 }; |
161 | 164 |
162 } } // namespace v8::internal | 165 } } // namespace v8::internal |
163 | 166 |
164 #endif // V8_LIST_H_ | 167 #endif // V8_LIST_H_ |
OLD | NEW |