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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 template<typename T, class P> | 98 template<typename T, class P> |
99 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) { | 99 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) { |
100 int start = length_; | 100 int start = length_; |
101 for (int i = 0; i < count; i++) Add(value, alloc); | 101 for (int i = 0; i < count; i++) Add(value, alloc); |
102 return Vector<T>(&data_[start], count); | 102 return Vector<T>(&data_[start], count); |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 template<typename T, class P> | 106 template<typename T, class P> |
| 107 void List<T, P>::Set(int index, const T& elm) { |
| 108 ASSERT(index >= 0 && index <= length_); |
| 109 data_[index] = elm; |
| 110 } |
| 111 |
| 112 |
| 113 template<typename T, class P> |
107 void List<T, P>::InsertAt(int index, const T& elm, P alloc) { | 114 void List<T, P>::InsertAt(int index, const T& elm, P alloc) { |
108 ASSERT(index >= 0 && index <= length_); | 115 ASSERT(index >= 0 && index <= length_); |
109 Add(elm, alloc); | 116 Add(elm, alloc); |
110 for (int i = length_ - 1; i > index; --i) { | 117 for (int i = length_ - 1; i > index; --i) { |
111 data_[i] = data_[i - 1]; | 118 data_[i] = data_[i - 1]; |
112 } | 119 } |
113 data_[index] = elm; | 120 data_[index] = elm; |
114 } | 121 } |
115 | 122 |
116 | 123 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 273 |
267 template <typename T> | 274 template <typename T> |
268 int SortedListBSearch(const List<T>& list, T elem) { | 275 int SortedListBSearch(const List<T>& list, T elem) { |
269 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); | 276 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); |
270 } | 277 } |
271 | 278 |
272 | 279 |
273 } } // namespace v8::internal | 280 } } // namespace v8::internal |
274 | 281 |
275 #endif // V8_LIST_INL_H_ | 282 #endif // V8_LIST_INL_H_ |
OLD | NEW |