28 #ifndef V8_LIST_INL_H_
29 #define V8_LIST_INL_H_
37 template<
typename T,
class P>
39 if (length_ < capacity_) {
40 data_[length_++] = element;
47 template<
typename T,
class P>
53 template<
typename T,
class P>
55 int result_length = length_ + other.length();
56 if (capacity_ < result_length) Resize(result_length, alloc);
57 for (
int i = 0; i < other.length(); i++) {
58 data_[length_ + i] = other.at(i);
60 length_ = result_length;
66 template<
typename T,
class P>
67 void List<T, P>::ResizeAdd(
const T& element,
P alloc) {
68 ResizeAddInternal(element, alloc);
72 template<
typename T,
class P>
73 void List<T, P>::ResizeAddInternal(
const T& element,
P alloc) {
74 ASSERT(length_ >= capacity_);
77 int new_capacity = 1 + 2 * capacity_;
81 Resize(new_capacity, alloc);
82 data_[length_++] = temp;
86 template<
typename T,
class P>
87 void List<T, P>::Resize(
int new_capacity,
P alloc) {
88 T* new_data = NewData(new_capacity, alloc);
89 memcpy(new_data, data_, capacity_ *
sizeof(
T));
90 List<T, P>::DeleteData(data_);
92 capacity_ = new_capacity;
96 template<
typename T,
class P>
99 for (
int i = 0; i < count; i++) Add(value, alloc);
104 template<
typename T,
class P>
106 ASSERT(index >= 0 && index <= length_);
108 for (
int i = length_ - 1; i > index; --i) {
109 data_[i] = data_[i - 1];
115 template<
typename T,
class P>
119 while (i < length_) {
120 data_[i] = data_[i + 1];
127 template<
typename T,
class P>
129 for (
int i = 0; i < length_; i++) {
130 if (data_[i] == elm) {
139 template<
typename T,
class P>
142 Initialize(length, allocator);
147 template<
typename T,
class P>
148 void List<T, P>::Clear() {
158 template<
typename T,
class P>
159 void List<T, P>::Rewind(
int pos) {
164 template<
typename T,
class P>
166 for (
int i = 0; i < length_; i++) callback(&data_[i]);
170 template<
typename T,
class P>
171 template<
class Visitor>
173 for (
int i = 0; i < length_; i++) visitor->Apply(&data_[i]);
177 template<
typename T,
class P>
179 for (
int i = 0; i < length_; i++) {
187 template<
typename T,
class P>
190 for (
int i = start; i <= end; i++) {
191 if (data_[i] == elm) ++result;
197 template<
typename T,
class P>
199 ToVector().Sort(cmp);
201 for (
int i = 1; i < length_; i++)
202 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0);
207 template<
typename T,
class P>
209 Sort(PointerValueCompare<T>);
213 template<
typename T,
class P>
216 data_ = (capacity > 0) ? NewData(capacity, allocator) :
NULL;
217 capacity_ = capacity;
222 template <
typename T,
typename P>
225 int high = list.length() - 1;
226 while (low <= high) {
227 int mid = (low + high) / 2;
228 T mid_elem = list[mid];
230 if (cmp(&mid_elem) > 0) {
234 if (cmp(&mid_elem) < 0) {
257 template <
typename T>
259 return SortedListBSearch<T, ElementCmp<T> > (list,
ElementCmp<T>(elem));
265 #endif // V8_LIST_INL_H_
void InsertAt(int index, const T &element, AllocationPolicy allocator=AllocationPolicy())
bool Contains(const T &elm) const
int operator()(const T *other)
#define ASSERT(condition)
Vector< T > ToVector() const
#define T(name, string, precedence)
int PointerValueCompare(const T *a, const T *b)
int CountOccurrences(const T &elm, int start, int end) const
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
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())