16 template<
typename T,
class P>
18 if (length_ < capacity_) {
19 data_[length_++] = element;
26 template<
typename T,
class P>
32 template<
typename T,
class P>
34 int result_length = length_ + other.length();
35 if (capacity_ < result_length) Resize(result_length, alloc);
36 for (
int i = 0;
i < other.length();
i++) {
37 data_[length_ +
i] = other.at(
i);
39 length_ = result_length;
45 template<
typename T,
class P>
47 ResizeAddInternal(element, alloc);
51 template<
typename T,
class P>
53 DCHECK(length_ >= capacity_);
56 int new_capacity = 1 + 2 * capacity_;
60 Resize(new_capacity, alloc);
61 data_[length_++] = temp;
65 template<
typename T,
class P>
68 T* new_data = NewData(new_capacity, alloc);
69 MemCopy(new_data, data_, length_ *
sizeof(
T));
72 capacity_ = new_capacity;
76 template<
typename T,
class P>
79 for (
int i = 0;
i < count;
i++) Add(value, alloc);
84 template<
typename T,
class P>
86 DCHECK(index >= 0 && index <= length_);
91 template<
typename T,
class P>
93 DCHECK(index >= 0 && index <= length_);
95 for (
int i = length_ - 1;
i > index; --
i) {
96 data_[
i] = data_[
i - 1];
102 template<
typename T,
class P>
106 while (
i < length_) {
107 data_[
i] = data_[
i + 1];
114 template<
typename T,
class P>
116 for (
int i = 0;
i < length_;
i++) {
117 if (data_[
i] == elm) {
126 template<
typename T,
class P>
127 void List<T, P>::Allocate(
int length,
P allocator) {
129 Initialize(length, allocator);
134 template<
typename T,
class P>
135 void List<T, P>::Clear() {
145 template<
typename T,
class P>
152 template<
typename T,
class P>
154 if (length_ < capacity_ / 4) {
155 Resize(capacity_ / 2, alloc);
160 template<
typename T,
class P>
162 for (
int i = 0;
i < length_;
i++) callback(&data_[
i]);
166 template<
typename T,
class P>
167 template<
class Visitor>
169 for (
int i = 0;
i < length_;
i++) visitor->Apply(&data_[
i]);
173 template<
typename T,
class P>
175 for (
int i = 0;
i < length_;
i++) {
183 template<
typename T,
class P>
186 for (
int i = start;
i <= end;
i++) {
187 if (data_[
i] == elm) ++result;
193 template<
typename T,
class P>
195 ToVector().Sort(cmp);
197 for (
int i = 1;
i < length_;
i++)
198 DCHECK(cmp(&data_[
i - 1], &data_[
i]) <= 0);
203 template<
typename T,
class P>
209 template<
typename T,
class P>
212 data_ = (capacity > 0) ? NewData(capacity, allocator) :
NULL;
213 capacity_ = capacity;
218 template <
typename T,
typename P>
221 int high = list.length() - 1;
222 while (low <= high) {
223 int mid = (low + high) / 2;
224 T mid_elem = list[mid];
226 if (cmp(&mid_elem) > 0) {
230 if (cmp(&mid_elem) < 0) {
253 template <
typename T>
255 return SortedListBSearch<T, ElementCmp<T> > (list,
ElementCmp<T>(elem));
int operator()(const T *other)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
void Set(int index, const T &element)
bool RemoveElement(const T &elm)
void AddAll(const List< T, AllocationPolicy > &other, AllocationPolicy allocator=AllocationPolicy())
void Iterate(void(*callback)(T *x))
int CountOccurrences(const T &elm, int start, int end) const
void InsertAt(int index, const T &element, AllocationPolicy allocator=AllocationPolicy())
void Resize(int new_capacity, AllocationPolicy allocator)
void ResizeAdd(const T &element, AllocationPolicy allocator)
bool Contains(const T &elm) const
Vector< T > AddBlock(T value, int count, AllocationPolicy allocator=AllocationPolicy())
void ResizeAddInternal(const T &element, AllocationPolicy allocator)
Vector< T > ToVector() const
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK_LE(v1, v2)
#define DCHECK(condition)
int PointerValueCompare(const T *a, const T *b)
int SortedListBSearch(const List< T > &list, P cmp)
void MemCopy(void *dest, const void *src, size_t size)
Debugger support for the V8 JavaScript engine.
#define T(name, string, precedence)