50 template <
typename T,
class AllocationPolicy>
53 explicit List(AllocationPolicy allocator = AllocationPolicy()) {
54 Initialize(0, allocator);
57 AllocationPolicy allocator = AllocationPolicy())) {
58 Initialize(capacity, allocator);
70 AllocationPolicy allocator = AllocationPolicy())) {
71 return allocator.New(static_cast<int>(size));
73 INLINE(
void operator delete(
void* p)) {
74 AllocationPolicy::Delete(p);
78 INLINE(
void operator delete(
void* p, AllocationPolicy allocator)) {
91 inline T&
last()
const {
return at(length_ - 1); }
98 INLINE(
bool is_empty()
const) {
return length_ == 0; }
99 INLINE(
int length()
const) {
return length_; }
100 INLINE(
int capacity()
const) {
return capacity_; }
108 void Add(
const T& element, AllocationPolicy allocator = AllocationPolicy());
112 AllocationPolicy allocator = AllocationPolicy());
116 AllocationPolicy allocator = AllocationPolicy());
119 void InsertAt(
int index,
const T& element,
120 AllocationPolicy allocator = AllocationPolicy());
123 void Set(
int index,
const T& element);
129 AllocationPolicy allocator = AllocationPolicy());
146 INLINE(
void Allocate(
int length,
147 AllocationPolicy allocator = AllocationPolicy()));
154 INLINE(
void Rewind(
int pos));
157 INLINE(
void RewindBy(
int count)) { Rewind(length_ - count); }
160 INLINE(
void Trim(AllocationPolicy allocator = AllocationPolicy()));
166 void Iterate(
void (*callback)(
T* x));
167 template<
class Visitor>
168 void Iterate(Visitor* visitor);
171 void Sort(
int (*cmp)(
const T* x,
const T* y));
174 INLINE(
void Initialize(
int capacity,
175 AllocationPolicy allocator = AllocationPolicy()));
182 INLINE(
T* NewData(
int n, AllocationPolicy allocator)) {
183 return static_cast<T*
>(allocator.New(n *
sizeof(
T)));
185 INLINE(
void DeleteData(
T* data)) {
186 AllocationPolicy::Delete(data);
191 void ResizeAdd(
const T& element, AllocationPolicy allocator);
195 void ResizeAddInternal(
const T& element, AllocationPolicy allocator);
198 void Resize(
int new_capacity, AllocationPolicy allocator);
200 DISALLOW_COPY_AND_ASSIGN(
List);
204 template<
typename T,
class P>
206 return list.length() *
sizeof(
T) +
sizeof(list);
227 template <
typename T,
class P>
229 template <
typename T>
#define SLOW_ASSERT(condition)
void InsertAt(int index, const T &element, AllocationPolicy allocator=AllocationPolicy())
bool Contains(const T &elm) const
Vector< const T > ToConstVector()
List< Handle< Map > > MapHandleList
#define ASSERT(condition)
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 size
INLINE(bool is_empty() const)
Vector< T > ToVector() const
List(AllocationPolicy allocator=AllocationPolicy())
INLINE(explicit List(int capacity, AllocationPolicy allocator=AllocationPolicy()))
List< Handle< HeapType > > TypeHandleList
INLINE(void *operator new(size_t size, AllocationPolicy allocator=AllocationPolicy()))
#define T(name, string, precedence)
List< Handle< Code > > CodeHandleList
void Set(int index, const T &element)
int CountOccurrences(const T &elm, int start, int end) const
size_t GetMemoryUsedByList(const List< T, P > &list)
INLINE(int length() const)
int SortedListBSearch(const List< T > &list, P cmp)
T & operator[](int i) const
INLINE(void operator delete(void *p, AllocationPolicy allocator))
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
void Iterate(void(*callback)(T *x))
TypeImpl< HeapTypeConfig > HeapType
INLINE(void RewindBy(int count))
Vector< T > AddBlock(T value, int count, AllocationPolicy allocator=AllocationPolicy())
bool RemoveElement(const T &elm)
INLINE(void operator delete(void *p))
void AddAll(const List< T, AllocationPolicy > &other, AllocationPolicy allocator=AllocationPolicy())
INLINE(int capacity() const)