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
int SortedListBSearch(const List< T > &list, P cmp)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
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())