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);
78 INLINE(
void operator delete(
void* p, AllocationPolicy allocator)) {
91 inline T&
last()
const {
return at(length_ - 1); }
94 INLINE(
bool is_empty()
const) {
return length_ == 0; }
95 INLINE(
int length()
const) {
return length_; }
96 INLINE(
int capacity()
const) {
return capacity_; }
104 void Add(
const T& element, AllocationPolicy allocator = AllocationPolicy());
108 AllocationPolicy allocator = AllocationPolicy());
112 AllocationPolicy allocator = AllocationPolicy());
115 void InsertAt(
int index,
const T& element,
116 AllocationPolicy allocator = AllocationPolicy());
122 AllocationPolicy allocator = AllocationPolicy());
139 INLINE(
void Allocate(
int length,
140 AllocationPolicy allocator = AllocationPolicy()));
147 INLINE(
void Rewind(
int pos));
150 INLINE(
void RewindBy(
int count)) { Rewind(length_ - count); }
156 void Iterate(
void (*callback)(
T* x));
157 template<
class Visitor>
158 void Iterate(Visitor* visitor);
161 void Sort(
int (*cmp)(
const T* x,
const T* y));
164 INLINE(
void Initialize(
int capacity,
165 AllocationPolicy allocator = AllocationPolicy()));
172 INLINE(
T* NewData(
int n, AllocationPolicy allocator)) {
173 return static_cast<T*
>(allocator.New(n *
sizeof(
T)));
175 INLINE(
void DeleteData(
T* data)) {
176 AllocationPolicy::Delete(data);
181 void ResizeAdd(
const T& element, AllocationPolicy allocator);
185 void ResizeAddInternal(
const T& element, AllocationPolicy allocator);
188 void Resize(
int new_capacity, AllocationPolicy allocator);
190 DISALLOW_COPY_AND_ASSIGN(
List);
206 template <
typename T,
class P>
208 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
INLINE(void operator delete(void *p, AllocationPolicy allocator))
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)