NGUI: Next-Gen UI kit  3.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
BetterList< T > Class Template Reference

This improved version of the System.Collections.Generic.List that doesn't release the buffer on Clear(), resulting in better performance and less garbage collection. PRO: BetterList performs faster than List when you Add and Remove items (although slower if you remove from the beginning). CON: BetterList performs worse when sorting the list. If your operations involve sorting, use the standard List instead. More...

Public Member Functions

IEnumerator< T > GetEnumerator ()
 For 'foreach' functionality. More...
 
void Clear ()
 Clear the array by resetting its size to zero. Note that the memory is not actually released. More...
 
void Release ()
 Clear the array and release the used memory. More...
 
void Add (T item)
 Add the specified item to the end of the list. More...
 
void Insert (int index, T item)
 Insert an item at the specified index, pushing the entries back. More...
 
bool Contains (T item)
 Returns 'true' if the specified item is within the list. More...
 
int IndexOf (T item)
 Return the index of the specified item. More...
 
bool Remove (T item)
 Remove the specified item from the list. Note that RemoveAt() is faster and is advisable if you already know the index. More...
 
void RemoveAt (int index)
 Remove an item at the specified index. More...
 
Pop ()
 Remove an item from the end. More...
 
T[] ToArray ()
 Mimic List's ToArray() functionality, except that in this case the list is resized to match the current size. More...
 
void Sort (CompareFunc comparer)
 List.Sort equivalent. Doing Array.Sort causes GC allocations. More...
 
delegate int CompareFunc (T left, T right)
 Comparison function should return -1 if left is less than right, 1 if left is greater than right, and 0 if they match. More...
 

Public Attributes

T[] buffer
 Direct access to the buffer. Note that you should not use its 'Length' parameter, but instead use BetterList.size. More...
 
int size = 0
 Direct access to the buffer's size. Note that it's only public for speed and efficiency. You shouldn't modify it. More...
 

Properties

this[int i] [get, set]
 Convenience function. I recommend using .buffer instead. More...
 

Detailed Description

This improved version of the System.Collections.Generic.List that doesn't release the buffer on Clear(), resulting in better performance and less garbage collection. PRO: BetterList performs faster than List when you Add and Remove items (although slower if you remove from the beginning). CON: BetterList performs worse when sorting the list. If your operations involve sorting, use the standard List instead.

Member Function Documentation

void BetterList< T >.Add ( item)

Add the specified item to the end of the list.

void BetterList< T >.Clear ( )

Clear the array by resetting its size to zero. Note that the memory is not actually released.

delegate int BetterList< T >.CompareFunc ( left,
right 
)

Comparison function should return -1 if left is less than right, 1 if left is greater than right, and 0 if they match.

bool BetterList< T >.Contains ( item)

Returns 'true' if the specified item is within the list.

IEnumerator<T> BetterList< T >.GetEnumerator ( )

For 'foreach' functionality.

int BetterList< T >.IndexOf ( item)

Return the index of the specified item.

void BetterList< T >.Insert ( int  index,
item 
)

Insert an item at the specified index, pushing the entries back.

T BetterList< T >.Pop ( )

Remove an item from the end.

void BetterList< T >.Release ( )

Clear the array and release the used memory.

bool BetterList< T >.Remove ( item)

Remove the specified item from the list. Note that RemoveAt() is faster and is advisable if you already know the index.

void BetterList< T >.RemoveAt ( int  index)

Remove an item at the specified index.

void BetterList< T >.Sort ( CompareFunc  comparer)

List.Sort equivalent. Doing Array.Sort causes GC allocations.

List.Sort equivalent. Manual sorting causes no GC allocations.

T [] BetterList< T >.ToArray ( )

Mimic List's ToArray() functionality, except that in this case the list is resized to match the current size.

Member Data Documentation

T [] BetterList< T >.buffer

Direct access to the buffer. Note that you should not use its 'Length' parameter, but instead use BetterList.size.

int BetterList< T >.size = 0

Direct access to the buffer's size. Note that it's only public for speed and efficiency. You shouldn't modify it.

Property Documentation

T BetterList< T >.this[int i]
getset

Convenience function. I recommend using .buffer instead.


The documentation for this class was generated from the following file: