Main Page Modules Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages
csArray< T, ElementHandler, MemoryAllocator > Class Template Reference
A templated array class.
More...
#include <array.h>
List of all members.
|
Public Methods |
| csArray (int icapacity=0, int ithreshold=0) |
| Initialize object to have initial capacity of 'icapacity' elements, and to increase storage by 'ithreshold' each time the upper bound is exceeded.
|
| csArray (const csArray &source) |
| Copy constructor.
|
csArray< T, ElementHandler > & | operator= (const csArray &other) |
| Assignment operator.
|
int | Length () const |
| Return the number of elements in the Array.
|
int | Capacity () const |
| Query vector capacity. Note that you should rarely need to do this.
|
void | TransferTo (csArray &destination) |
| Transfer the entire contents of one array to the other.
|
void | SetLength (int n, T const &what) |
| Set the actual number of items in this array.
|
void | SetLength (int n) |
| Set vector length to n.
|
T & | Get (int n) |
| Get an element (non-const).
|
T const & | Get (int n) const |
| Get an element (const).
|
T & | GetExtend (int n) |
| Get an item from the array.
|
T & | operator[] (int n) |
| Get an element (non-const).
|
T const & | operator[] (int n) const |
| Get a const reference.
|
void | Put (int n, T const &what) |
| Put an element at some position.
|
| csArrayTemplate (K) int FindKey(csArrayCmpDecl(T |
| Find an element based on some key.
|
Iterator | GetIterator () const |
| Returns an Iterator which traverses the Array.
|
Static Public Methods |
int | DefaultCompare (T const &r1, T const &r2) |
| Compare two objects of the same type.
|
Protected Methods |
void | InitRegion (int start, int count) |
| Initialize a region.
|
Detailed Description
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>>
class csArray< T, ElementHandler, MemoryAllocator >
A templated array class.
The objects in this class are constructed via copy-constructor and are destroyed when they are removed from the array or the array is destroyed. Note: If you want to store reference-counted object pointers (such as iSomething*), then you should look at csRefArray instead of this class.
Definition at line 275 of file array.h.
Constructor & Destructor Documentation
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
csArray< T, ElementHandler, MemoryAllocator >::csArray |
( |
int |
icapacity = 0, |
|
|
int |
ithreshold = 0 |
|
) |
[inline] |
|
|
Initialize object to have initial capacity of 'icapacity' elements, and to increase storage by 'ithreshold' each time the upper bound is exceeded.
Definition at line 381 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
csArray< T, ElementHandler, MemoryAllocator >::csArray |
( |
const csArray< T, ElementHandler, MemoryAllocator > & |
source |
) |
[inline] |
|
|
Copy constructor.
Definition at line 408 of file array.h. |
Member Function Documentation
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
int csArray< T, ElementHandler, MemoryAllocator >::Capacity |
( |
|
) |
const [inline] |
|
|
Query vector capacity. Note that you should rarely need to do this.
Definition at line 433 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
csArray< T, ElementHandler, MemoryAllocator >::csArrayTemplate |
( |
K |
|
) |
|
|
|
Find an element based on some key.
|
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
int csArray< T, ElementHandler, MemoryAllocator >::DefaultCompare |
( |
T const & |
r1, |
|
|
T const & |
r2 |
|
) |
[inline, static] |
|
|
Compare two objects of the same type.
- Parameters:
-
r1 |
Reference to first object. |
r2 |
Reference to second object. |
- Returns:
-
Zero if the objects are equal; less-than-zero if the first object is less than the second; or greater-than-zero if the first object is greater than the second.
- Remarks:
-
Assumes the existence of T::operator<(T). This is the default comparison function used by csArray for sorting if the client does not provide a custom function.
Definition at line 372 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
T const& csArray< T, ElementHandler, MemoryAllocator >::Get |
( |
int |
n |
) |
const [inline] |
|
|
Get an element (const).
Definition at line 507 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
T& csArray< T, ElementHandler, MemoryAllocator >::Get |
( |
int |
n |
) |
[inline] |
|
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
T& csArray< T, ElementHandler, MemoryAllocator >::GetExtend |
( |
int |
n |
) |
[inline] |
|
|
Get an item from the array.
If the number of elements in this array is too small the array will be automatically extended.
Definition at line 517 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
Iterator csArray< T, ElementHandler, MemoryAllocator >::GetIterator |
( |
|
) |
const [inline] |
|
|
Returns an Iterator which traverses the Array.
Definition at line 893 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
void csArray< T, ElementHandler, MemoryAllocator >::InitRegion |
( |
int |
start, |
|
|
int |
count |
|
) |
[inline, protected] |
|
|
Initialize a region.
This is a dangerous function to use because it does not properly destruct the items in the array.
Definition at line 307 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
int csArray< T, ElementHandler, MemoryAllocator >::Length |
( |
|
) |
const [inline] |
|
|
Return the number of elements in the Array.
Definition at line 427 of file array.h.
Referenced by csTreeNode::BSF(), csBlockAllocator< csBSPTree >::Compact(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::Delete(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::DeleteAll(), csBlockAllocator< csBSPTree >::Dump(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::Get(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::GetAll(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::GetElementPointer(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::In(), csTree< T >::PopulateWith(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::Put(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::PutFirst(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::SetLength(), and csBlockAllocator< csBSPTree >::~csBlockAllocator(). |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
csArray<T,ElementHandler>& csArray< T, ElementHandler, MemoryAllocator >::operator= |
( |
const csArray< T, ElementHandler, MemoryAllocator > & |
other |
) |
[inline] |
|
|
Assignment operator.
Definition at line 420 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
T const& csArray< T, ElementHandler, MemoryAllocator >::operator[] |
( |
int |
n |
) |
const [inline] |
|
|
Get a const reference.
Definition at line 532 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
T& csArray< T, ElementHandler, MemoryAllocator >::operator[] |
( |
int |
n |
) |
[inline] |
|
|
Get an element (non-const).
Definition at line 526 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
void csArray< T, ElementHandler, MemoryAllocator >::Put |
( |
int |
n, |
|
|
T const & |
what |
|
) |
[inline] |
|
|
Put an element at some position.
Definition at line 538 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
void csArray< T, ElementHandler, MemoryAllocator >::SetLength |
( |
int |
n |
) |
[inline] |
|
|
Set vector length to n.
Reimplemented in csPDelArray< T >, csPDelArray< cspPageData >, csPDelArray< csPlugin >, csPDelArray< csMousePointer >, csPDelArray< ArchiveEntry >, csPDelArray< csSkinSliceNonAbstr >, csPDelArray< csWSTexture >, csPDelArray< renderMeshListInfo >, csPDelArray< csPixmap >, csPDelArray< csLayoutConstraint >, csPDelArray< csPluginLoadRec >, csPDelArray< csRect >, csPDelArray< csGridRowEntry >, csPDelArray< csAccElement >, csPDelArray< csCommandLineOption >, and csPDelArray< csPluginOption >.
Definition at line 485 of file array.h. |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
void csArray< T, ElementHandler, MemoryAllocator >::SetLength |
( |
int |
n, |
|
|
T const & |
what |
|
) |
[inline] |
|
|
Set the actual number of items in this array.
This can be used to shrink an array (works like Truncate() then in which case it will properly destroy all truncated objects) or to enlarge an array in which case it will properly set the new capacity and construct all new items based on the given item.
Reimplemented in csPDelArray< T >, csPDelArray< cspPageData >, csPDelArray< csPlugin >, csPDelArray< csMousePointer >, csPDelArray< ArchiveEntry >, csPDelArray< csSkinSliceNonAbstr >, csPDelArray< csWSTexture >, csPDelArray< renderMeshListInfo >, csPDelArray< csPixmap >, csPDelArray< csLayoutConstraint >, csPDelArray< csPluginLoadRec >, csPDelArray< csRect >, csPDelArray< csGridRowEntry >, csPDelArray< csAccElement >, csPDelArray< csCommandLineOption >, and csPDelArray< csPluginOption >.
Definition at line 469 of file array.h.
Referenced by csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::csHash(), csHash< KeyInfo, csStrKey, csConstCharHashKeyHandler >::DeleteAll(), csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::GetExtend(), and csArray< csShaderVariable *, csRefArrayElementHandler< csShaderVariable * > >::Put(). |
template<class T, class ElementHandler = csArrayElementHandler<T>, class MemoryAllocator = csArrayMemoryAllocator<T>> |
void csArray< T, ElementHandler, MemoryAllocator >::TransferTo |
( |
csArray< T, ElementHandler, MemoryAllocator > & |
destination |
) |
[inline] |
|
|
Transfer the entire contents of one array to the other.
The end result will be that this array will be completely empty and the other array will have all items that originally were in this array. This operation is very efficient.
Definition at line 444 of file array.h. |
The documentation for this class was generated from the following file:
Generated for Crystal Space by
doxygen 1.2.18