28 #ifndef V8_LIST_INL_H_
29 #define V8_LIST_INL_H_
38 template<
typename T,
class P>
40 if (length_ < capacity_) {
41 data_[length_++] = element;
48 template<
typename T,
class P>
54 template<
typename T,
class P>
56 int result_length = length_ + other.length();
57 if (capacity_ < result_length) Resize(result_length, alloc);
58 for (
int i = 0; i < other.length(); i++) {
59 data_[length_ + i] = other.at(i);
61 length_ = result_length;
67 template<
typename T,
class P>
68 void List<T, P>::ResizeAdd(
const T& element,
P alloc) {
69 ResizeAddInternal(element, alloc);
73 template<
typename T,
class P>
74 void List<T, P>::ResizeAddInternal(
const T& element,
P alloc) {
75 ASSERT(length_ >= capacity_);
78 int new_capacity = 1 + 2 * capacity_;
82 Resize(new_capacity, alloc);
83 data_[length_++] = temp;
87 template<
typename T,
class P>
88 void List<T, P>::Resize(
int new_capacity,
P alloc) {
90 T* new_data = NewData(new_capacity, alloc);
92 List<T, P>::DeleteData(data_);
94 capacity_ = new_capacity;
98 template<
typename T,
class P>
101 for (
int i = 0; i < count; i++) Add(value, alloc);
106 template<
typename T,
class P>
108 ASSERT(index >= 0 && index <= length_);
113 template<
typename T,
class P>
115 ASSERT(index >= 0 && index <= length_);
117 for (
int i = length_ - 1; i > index; --i) {
118 data_[i] = data_[i - 1];
124 template<
typename T,
class P>
128 while (i < length_) {
129 data_[i] = data_[i + 1];
136 template<
typename T,
class P>
138 for (
int i = 0; i < length_; i++) {
139 if (data_[i] == elm) {
148 template<
typename T,
class P>
151 Initialize(length, allocator);
156 template<
typename T,
class P>
157 void List<T, P>::Clear() {
167 template<
typename T,
class P>
168 void List<T, P>::Rewind(
int pos) {
169 ASSERT(0 <= pos && pos <= length_);
174 template<
typename T,
class P>
175 void List<T, P>::Trim(
P alloc) {
176 if (length_ < capacity_ / 4) {
177 Resize(capacity_ / 2, alloc);
182 template<
typename T,
class P>
184 for (
int i = 0; i < length_; i++) callback(&data_[i]);
188 template<
typename T,
class P>
189 template<
class Visitor>
191 for (
int i = 0; i < length_; i++) visitor->Apply(&data_[i]);
195 template<
typename T,
class P>
197 for (
int i = 0; i < length_; i++) {
205 template<
typename T,
class P>
208 for (
int i = start; i <= end; i++) {
209 if (data_[i] == elm) ++result;
215 template<
typename T,
class P>
217 ToVector().Sort(cmp);
219 for (
int i = 1; i < length_; i++)
220 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0);
225 template<
typename T,
class P>
231 template<
typename T,
class P>
234 data_ = (capacity > 0) ? NewData(capacity, allocator) :
NULL;
235 capacity_ = capacity;
240 template <
typename T,
typename P>
243 int high = list.length() - 1;
244 while (low <= high) {
245 int mid = (low + high) / 2;
246 T mid_elem = list[mid];
248 if (cmp(&mid_elem) > 0) {
252 if (cmp(&mid_elem) < 0) {
275 template <
typename T>
277 return SortedListBSearch<T, ElementCmp<T> > (list,
ElementCmp<T>(elem));
283 #endif // V8_LIST_INL_H_
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void InsertAt(int index, const T &element, AllocationPolicy allocator=AllocationPolicy())
bool Contains(const T &elm) const
int operator()(const T *other)
#define ASSERT(condition)
static void MemCopy(void *dest, const void *src, size_t size)
Vector< T > ToVector() const
#define ASSERT_LE(v1, v2)
#define T(name, string, precedence)
int PointerValueCompare(const T *a, const T *b)
void Set(int index, const T &element)
int CountOccurrences(const T &elm, int start, int end) const
int SortedListBSearch(const List< T > &list, P cmp)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
void Iterate(void(*callback)(T *x))
Vector< T > AddBlock(T value, int count, AllocationPolicy allocator=AllocationPolicy())
bool RemoveElement(const T &elm)
void AddAll(const List< T, AllocationPolicy > &other, AllocationPolicy allocator=AllocationPolicy())