#include <mi32/simplear.h>
Inheritance diagram for SIMPLE_ARRAY< _CT >:

Public Member Functions | |
| void | AddRef () |
| ERRVALUE | Append (const SIMPLE_ARRAY< _CT > &rhs) |
| ERRVALUE | Append (const _CT *items, int numitems) |
| ERRVALUE | Append (const _CT &item) |
| void | AppendExc (const SIMPLE_ARRAY< _CT > &rhs) |
| void | AppendExc (const _CT *items, int numitems) |
| void | AppendExc (const _CT &item) |
| ERRVALUE | AppendUnique (const _CT &item) |
| void | AppendUniqueExc (const _CT &item) |
| ERRVALUE | Assign (const _CT *items, int numitems) |
| void | Attach (_CT *&items, int numitems) |
| void | Clear () |
| void | ClearItems (int start=0, int end=-1) |
| ERRVALUE | Copy (const SIMPLE_ARRAY< _CT > &rhs) |
| operator _CT * () | |
| operator const _CT * () const | |
| bool | operator!= (const SIMPLE_ARRAY< _CT > &rhs) const |
| SIMPLE_ARRAY< _CT > & | operator= (const SIMPLE_ARRAY< _CT > &rhs) |
| bool | operator== (const SIMPLE_ARRAY< _CT > &rhs) const |
| template<typename _IDXTYPE> | |
| _CT & | operator[] (_IDXTYPE index) |
| template<typename _IDXTYPE> | |
| const _CT & | operator[] (_IDXTYPE index) const |
| SIMPLE_ARRAY (const SIMPLE_ARRAY< _CT > &rhs) | |
| SIMPLE_ARRAY () | |
| ~SIMPLE_ARRAY () | |
| _CT * | Detach () |
| void | Free () |
| const _CT & | GetItem (int index) const |
| const _CT & | GetLast () const |
| int | GetMaxItems () const |
| int | GetNumItems () const |
| UINT32 | GetRefCount () const |
| int | GetSizeInBytes () const |
| bool | HasItem (const _CT &item) const |
| void | InsertItems (int start, int num=1) |
| bool | IsEmpty () const |
| template<class _Pr1> | |
| INT32 | Locate (const _CT &item, _Pr1 _Pr, bool bReturnNegativeOneIfNotFound=false) const |
| void | Release () |
| void | RemoveDuplicates () |
| void | RemoveFast (INT32 item) |
| void | RemoveItem (INT32 item) |
| void | RemoveLast (INT32 count=1) |
| bool | RemoveMatchingItems (const _CT &item) |
| ERRVALUE | Reserve (int newmaxitems, bool clear=false) |
| void | ReserveExc (int newmaxitems, bool clear=false) |
| ERRVALUE | Resize (int numitems, bool keepold=true, bool clear=false) |
| void | Reverse () |
| void | SetItem (int index, const _CT &item) |
| ERRVALUE | SetItems (int firstitem, const _CT *items, int numitems) |
| void | Sort (int(*CompFunc)(_CT *, _CT *, void *), void *data=0) |
| void | SortRange (int(*CompFunc)(_CT *, _CT *, void *), int firstidx, int numitems, void *data=0) |
| void | Swap (SIMPLE_ARRAY< _CT > &rhs) |
| void | SwapBytes () |
This template is designed to contain an array of items which can be allocated using MmAlloc/MmRealloc. The primary purpose of this template is to replace allocated arrays where direct access to both array elements and the ability to access a pointer to the first element (as for a C array) is required. Do not use this template with classes which require constructors or have virtual methods or which do not have compiler-generated assignment operators.
For maximum efficiency, only minimal validation of access to array elements is performed. No initialization of array items is performed by the template.
For doubles and objects based on doubles, use DOUBLE_ARRAY<> in mi32/doublear.h
Instances of this class are passed to DLLs, so do not add or remove members.
Definition at line 212 of file simplear.h.
| SIMPLE_ARRAY< _CT >::SIMPLE_ARRAY | ( | ) | [inline] |
| SIMPLE_ARRAY< _CT >::SIMPLE_ARRAY | ( | const SIMPLE_ARRAY< _CT > & | rhs | ) | [inline] |
| SIMPLE_ARRAY< _CT >::~SIMPLE_ARRAY | ( | ) | [inline] |
| void SIMPLE_ARRAY< _CT >::AddRef | ( | ) | [inline] |
| ERRVALUE SIMPLE_ARRAY< _CT >::Append | ( | const SIMPLE_ARRAY< _CT > & | rhs | ) | [inline] |
Append items from SIMPLE_ARRAY reserving space if needed.
Definition at line 338 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::Append | ( | const _CT * | items, | |
| int | numitems | |||
| ) | [inline] |
Append items from C array, reserving space if needed.
| items | Items to append |
| numitems | Number of items to append |
Definition at line 326 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::Append | ( | const _CT & | item | ) | [inline] |
Append item to end of array, extending if necessary.
Reimplemented in MENUITEMARRAY, and BUTTONITEMARRAY.
Definition at line 314 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::AppendExc | ( | const SIMPLE_ARRAY< _CT > & | rhs | ) | [inline] |
Append items from SIMPLE_ARRAY reserving space if needed.
Throws exception if out of memory.
Definition at line 374 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::AppendExc | ( | const _CT * | items, | |
| int | numitems | |||
| ) | [inline] |
Append items from C array, reserving space if needed.
Throws exception if out of memory.
| items | Items to append |
| numitems | Number of items to append |
Definition at line 362 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::AppendExc | ( | const _CT & | item | ) | [inline] |
Append item to end of array, extending if necessary.
Throws exception if out of memory.
Definition at line 350 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::AppendUnique | ( | const _CT & | item | ) | [inline] |
Append item to end of array if unique, extending if necessary.
Definition at line 384 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::AppendUniqueExc | ( | const _CT & | item | ) | [inline] |
Append item to end of array if unique, extending if necessary.
Throws exception if out of memory.
Definition at line 396 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::Assign | ( | const _CT * | items, | |
| int | numitems | |||
| ) | [inline] |
Assign from C array, reserving space if needed.
Resizes the array to the specified number of items.
| items | Items to copy to array |
| numitems | Number of items to copy |
Definition at line 409 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::Attach | ( | _CT *& | items, | |
| int | numitems | |||
| ) | [inline] |
Attach a buffer to the SIMPLE_ARRAY.
After passing a buffer to Attach(), the SIMPLE_ARRAY "<b>owns</b>" the buffer and will free it in its destructor.
| items | Reference to a pointer to the templated data type. The reason it's a reference is that after recording the pointer, Attach() will set your pointer to 0. This will prevent you from accidently freeing a pointer you no longer own. If you want it back, call the Detach() method |
| numitems | Number of items in array |
Definition at line 428 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::Clear | ( | ) | [inline] |
| void SIMPLE_ARRAY< _CT >::ClearItems | ( | int | start = 0, |
|
| int | end = -1 | |||
| ) | [inline] |
Clear items in the array.
Start might be larger than end
| end | Default -1, use number of items |
Definition at line 448 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::Copy | ( | const SIMPLE_ARRAY< _CT > & | rhs | ) | [inline] |
Copy the contents of another SIMPLE_ARRAY.
Same as assignment, but returns an error code instead of throwing an exception.
Free the old array instead of using realloc to avoid expensive copy.
Definition at line 462 of file simplear.h.
| _CT* SIMPLE_ARRAY< _CT >::Detach | ( | ) | [inline] |
Detach the buffer from the SIMPLE_ARRAY.
This turns ownership of the buffer over to the caller, who is then responsibile for seeing that it gets disposed of. After calling Detach(), the SIMPLE_ARRAY will behave as if it had just been constructed. In other words, it will be a NULL pointer pointing to 0 items. This means that if you want to know how many items are in the array returned, you'd better find out before} you call Detach()!
Definition at line 488 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::Free | ( | ) | [inline] |
| const _CT& SIMPLE_ARRAY< _CT >::GetItem | ( | int | index | ) | const [inline] |
| const _CT& SIMPLE_ARRAY< _CT >::GetLast | ( | ) | const [inline] |
Get last item in array.
Does not verify that array is non-empty.
Definition at line 511 of file simplear.h.
| int SIMPLE_ARRAY< _CT >::GetMaxItems | ( | ) | const [inline] |
| int SIMPLE_ARRAY< _CT >::GetNumItems | ( | ) | const [inline] |
| UINT32 SIMPLE_ARRAY< _CT >::GetRefCount | ( | ) | const [inline] |
| int SIMPLE_ARRAY< _CT >::GetSizeInBytes | ( | ) | const [inline] |
Get size of array required to hold current number of items in bytes.
Definition at line 527 of file simplear.h.
| bool SIMPLE_ARRAY< _CT >::HasItem | ( | const _CT & | item | ) | const [inline] |
Determine if an item exists in the array.
Item must have a valid operator==()
Definition at line 533 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::InsertItems | ( | int | start, | |
| int | num = 1 | |||
| ) | [inline] |
| bool SIMPLE_ARRAY< _CT >::IsEmpty | ( | ) | const [inline] |
| INT32 SIMPLE_ARRAY< _CT >::Locate | ( | const _CT & | item, | |
| _Pr1 | _Pr, | |||
| bool | bReturnNegativeOneIfNotFound = false | |||
| ) | const [inline] |
Binary search for an entry or the place where the entry should be _Pr is a functor that returns -1 if 1st item < 2nd, 1 if 1st > 2nd, 0 if 1st == 2nd 'item' is the first parameter passed to the _Pr functor.
Definition at line 562 of file simplear.h.
| SIMPLE_ARRAY< _CT >::operator _CT * | ( | ) | [inline] |
| SIMPLE_ARRAY< _CT >::operator const _CT * | ( | ) | const [inline] |
| bool SIMPLE_ARRAY< _CT >::operator!= | ( | const SIMPLE_ARRAY< _CT > & | rhs | ) | const [inline] |
| SIMPLE_ARRAY<_CT>& SIMPLE_ARRAY< _CT >::operator= | ( | const SIMPLE_ARRAY< _CT > & | rhs | ) | [inline] |
Assignment.
Free the old array instead of using realloc to avoid expensive copy.
Definition at line 247 of file simplear.h.
| bool SIMPLE_ARRAY< _CT >::operator== | ( | const SIMPLE_ARRAY< _CT > & | rhs | ) | const [inline] |
| _CT& SIMPLE_ARRAY< _CT >::operator[] | ( | _IDXTYPE | index | ) | [inline] |
Write (non-const) access to array element.
Definition at line 303 of file simplear.h.
| const _CT& SIMPLE_ARRAY< _CT >::operator[] | ( | _IDXTYPE | index | ) | const [inline] |
Read (const) access to array element.
Definition at line 294 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::Release | ( | ) | [inline] |
| void SIMPLE_ARRAY< _CT >::RemoveDuplicates | ( | ) | [inline] |
| void SIMPLE_ARRAY< _CT >::RemoveFast | ( | INT32 | item | ) | [inline] |
| void SIMPLE_ARRAY< _CT >::RemoveItem | ( | INT32 | item | ) | [inline] |
Remove item at specified index, maintaining order.
Note that this is inefficient for large arrays.
Definition at line 617 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::RemoveLast | ( | INT32 | count = 1 |
) | [inline] |
Remove last item(s) from array.
| count | Number of items to remove |
Definition at line 628 of file simplear.h.
| bool SIMPLE_ARRAY< _CT >::RemoveMatchingItems | ( | const _CT & | item | ) | [inline] |
Remove items matching the item passed in.
_CT must have a operator==() defined Maintains item order
Definition at line 641 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::Reserve | ( | int | newmaxitems, | |
| bool | clear = false | |||
| ) | [inline] |
Reserve space in array for up to specified number of items.
Free the old array to avoid expensive copy in reallocation
| newmaxitems | New maximum number of items |
| clear | Clear the array by resetting number of items to 0 |
Definition at line 657 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::ReserveExc | ( | int | newmaxitems, | |
| bool | clear = false | |||
| ) | [inline] |
Reserve space in array for up to specified number of items.
Throws exception if out of memory.
Free the old array to avoid expensive copy in reallocation
| newmaxitems | New maximum number of items |
| clear | Clear the array by resetting number of items to 0 |
Definition at line 676 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::Resize | ( | int | numitems, | |
| bool | keepold = true, |
|||
| bool | clear = false | |||
| ) | [inline] |
Resize array to specified number of items.
If the new size is larger than the previous size and the array is not cleared the new array entries will have indeterminant values.
| numitems | New number of items desired |
| keepold | Keep old array entries |
| clear | Clear new array items to zeros |
Definition at line 695 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::Reverse | ( | ) | [inline] |
| void SIMPLE_ARRAY< _CT >::SetItem | ( | int | index, | |
| const _CT & | item | |||
| ) | [inline] |
Set single item, does not verify index range.
| index | Item index, must be in range from 0 to NumItems-1 |
| item | Item value to set |
Definition at line 719 of file simplear.h.
| ERRVALUE SIMPLE_ARRAY< _CT >::SetItems | ( | int | firstitem, | |
| const _CT * | items, | |||
| int | numitems | |||
| ) | [inline] |
Set array items from C array, expanding if needed.
Will not reduce the number of items in the array.
| firstitem | First array item to replace |
| items | Items to copy to array |
| numitems | Number of items to copy |
Definition at line 728 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::Sort | ( | int(*)(_CT *, _CT *, void *) | CompFunc, | |
| void * | data = 0 | |||
| ) | [inline] |
Sort the items in the array.
CompFunc should return 1 if the first item sorts before the 2nd item Otherwise, return 0.
Definition at line 743 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::SortRange | ( | int(*)(_CT *, _CT *, void *) | CompFunc, | |
| int | firstidx, | |||
| int | numitems, | |||
| void * | data = 0 | |||
| ) | [inline] |
Sort the items in the array.
CompFunc should return 1 if the first item sorts before the 2nd item Otherwise, return 0.
Definition at line 754 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::Swap | ( | SIMPLE_ARRAY< _CT > & | rhs | ) | [inline] |
Swap (exchange) two SIMPLE_ARRAYs.
This exchanges the internal buffers so minimal copying is performed for efficiency.
Definition at line 766 of file simplear.h.
| void SIMPLE_ARRAY< _CT >::SwapBytes | ( | ) | [inline] |
Swap bytes in a SIMPLE_ARRAY, assume that there is an overload to swap a _CT.
Definition at line 781 of file simplear.h.
1.5.2