50 template <
typename T,
class AllocationPolicy>
53 explicit List(AllocationPolicy allocator = AllocationPolicy()) {
54 Initialize(0, allocator);
57 AllocationPolicy allocator = AllocationPolicy())) {
58 Initialize(capacity, allocator);
69 INLINE(
void*
operator new(
size_t size,
70 AllocationPolicy allocator = AllocationPolicy())) {
71 return allocator.New(static_cast<int>(size));
73 INLINE(
void operator delete(
void* p)) {
74 AllocationPolicy::Delete(p);
86 inline T&
last()
const {
return at(length_ - 1); }
89 INLINE(
bool is_empty()
const) {
return length_ == 0; }
90 INLINE(
int length()
const) {
return length_; }
91 INLINE(
int capacity()
const) {
return capacity_; }
99 void Add(
const T& element, AllocationPolicy allocator = AllocationPolicy());
103 AllocationPolicy allocator = AllocationPolicy());
107 AllocationPolicy allocator = AllocationPolicy());
110 void InsertAt(
int index,
const T& element,
111 AllocationPolicy allocator = AllocationPolicy());
117 AllocationPolicy allocator = AllocationPolicy());
134 INLINE(
void Allocate(
int length,
135 AllocationPolicy allocator = AllocationPolicy()));
142 INLINE(
void Rewind(
int pos));
145 INLINE(
void RewindBy(
int count)) { Rewind(length_ - count); }
151 void Iterate(
void (*callback)(
T* x));
152 template<
class Visitor>
153 void Iterate(Visitor* visitor);
156 void Sort(
int (*cmp)(
const T* x,
const T* y));
159 INLINE(
void Initialize(
int capacity,
160 AllocationPolicy allocator = AllocationPolicy()));
167 INLINE(
T* NewData(
int n, AllocationPolicy allocator)) {
168 return static_cast<T*
>(allocator.New(n *
sizeof(
T)));
170 INLINE(
void DeleteData(
T* data)) {
171 AllocationPolicy::Delete(data);
176 void ResizeAdd(
const T& element, AllocationPolicy allocator);
180 void ResizeAddInternal(
const T& element, AllocationPolicy allocator);
183 void Resize(
int new_capacity, AllocationPolicy allocator);
185 DISALLOW_COPY_AND_ASSIGN(
List);
201 template <
typename T,
class P>
203 template <
typename T>
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)
INLINE(bool is_empty() const)
Vector< T > ToVector() const
List(AllocationPolicy allocator=AllocationPolicy())
INLINE(explicit List(int capacity, AllocationPolicy allocator=AllocationPolicy()))
INLINE(void *operator new(size_t size, AllocationPolicy allocator=AllocationPolicy()))
#define T(name, string, precedence)
List< Handle< Code > > CodeHandleList
int CountOccurrences(const T &elm, int start, int end) const
INLINE(int length() const)
int SortedListBSearch(const List< T > &list, P cmp)
T & operator[](int i) const
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
void Iterate(void(*callback)(T *x))
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)