| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // backing store (e.g. Add). | 84 // backing store (e.g. Add). |
| 85 inline T& operator[](int i) const { | 85 inline T& operator[](int i) const { |
| 86 ASSERT(0 <= i); | 86 ASSERT(0 <= i); |
| 87 SLOW_ASSERT(i < length_); | 87 SLOW_ASSERT(i < length_); |
| 88 return data_[i]; | 88 return data_[i]; |
| 89 } | 89 } |
| 90 inline T& at(int i) const { return operator[](i); } | 90 inline T& at(int i) const { return operator[](i); } |
| 91 inline T& last() const { return at(length_ - 1); } | 91 inline T& last() const { return at(length_ - 1); } |
| 92 inline T& first() const { return at(0); } | 92 inline T& first() const { return at(0); } |
| 93 | 93 |
| 94 typedef T* iterator; |
| 95 inline iterator begin() const { return &data_[0]; } |
| 96 inline iterator end() const { return &data_[length_]; } |
| 97 |
| 94 INLINE(bool is_empty() const) { return length_ == 0; } | 98 INLINE(bool is_empty() const) { return length_ == 0; } |
| 95 INLINE(int length() const) { return length_; } | 99 INLINE(int length() const) { return length_; } |
| 96 INLINE(int capacity() const) { return capacity_; } | 100 INLINE(int capacity() const) { return capacity_; } |
| 97 | 101 |
| 98 Vector<T> ToVector() const { return Vector<T>(data_, length_); } | 102 Vector<T> ToVector() const { return Vector<T>(data_, length_); } |
| 99 | 103 |
| 100 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } | 104 Vector<const T> ToConstVector() { return Vector<const T>(data_, length_); } |
| 101 | 105 |
| 102 // Adds a copy of the given 'element' to the end of the list, | 106 // Adds a copy of the given 'element' to the end of the list, |
| 103 // expanding the list if necessary. | 107 // expanding the list if necessary. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 203 |
| 200 template<typename T, class P> | 204 template<typename T, class P> |
| 201 size_t GetMemoryUsedByList(const List<T, P>& list) { | 205 size_t GetMemoryUsedByList(const List<T, P>& list) { |
| 202 return list.length() * sizeof(T) + sizeof(list); | 206 return list.length() * sizeof(T) + sizeof(list); |
| 203 } | 207 } |
| 204 | 208 |
| 205 | 209 |
| 206 class Map; | 210 class Map; |
| 207 template<class> class TypeImpl; | 211 template<class> class TypeImpl; |
| 208 struct HeapTypeConfig; | 212 struct HeapTypeConfig; |
| 209 typedef TypeImpl<HeapTypeConfig> Type; | 213 typedef TypeImpl<HeapTypeConfig> HeapType; |
| 210 class Code; | 214 class Code; |
| 211 template<typename T> class Handle; | 215 template<typename T> class Handle; |
| 212 typedef List<Map*> MapList; | 216 typedef List<Map*> MapList; |
| 213 typedef List<Code*> CodeList; | 217 typedef List<Code*> CodeList; |
| 214 typedef List<Handle<Map> > MapHandleList; | 218 typedef List<Handle<Map> > MapHandleList; |
| 215 typedef List<Handle<Type> > TypeHandleList; | 219 typedef List<Handle<HeapType> > TypeHandleList; |
| 216 typedef List<Handle<Code> > CodeHandleList; | 220 typedef List<Handle<Code> > CodeHandleList; |
| 217 | 221 |
| 218 // Perform binary search for an element in an already sorted | 222 // Perform binary search for an element in an already sorted |
| 219 // list. Returns the index of the element of -1 if it was not found. | 223 // list. Returns the index of the element of -1 if it was not found. |
| 220 // |cmp| is a predicate that takes a pointer to an element of the List | 224 // |cmp| is a predicate that takes a pointer to an element of the List |
| 221 // and returns +1 if it is greater, -1 if it is less than the element | 225 // and returns +1 if it is greater, -1 if it is less than the element |
| 222 // being searched. | 226 // being searched. |
| 223 template <typename T, class P> | 227 template <typename T, class P> |
| 224 int SortedListBSearch(const List<T>& list, P cmp); | 228 int SortedListBSearch(const List<T>& list, P cmp); |
| 225 template <typename T> | 229 template <typename T> |
| 226 int SortedListBSearch(const List<T>& list, T elem); | 230 int SortedListBSearch(const List<T>& list, T elem); |
| 227 | 231 |
| 228 | 232 |
| 229 } } // namespace v8::internal | 233 } } // namespace v8::internal |
| 230 | 234 |
| 231 | 235 |
| 232 #endif // V8_LIST_H_ | 236 #endif // V8_LIST_H_ |
| OLD | NEW |