![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |


Each element of the SFXArray instance ( array ) needs to be data not more than 4 bytes. In order to process data more than 4 bytes ( such as UInt64 type, Double type, and so on ) or class instance as an element of the SFXArray instance ( array ), a pointer should be used.
// data more than 4 bytes or class instance cannot be an element of the SFXArray instance ( array ) // SFXArray<SInt64> ar64; NG // SFXArray<SFXAnsiString> arstr; NG // but a pointer to the data more than 4 bytes or class instance can be an element of the SFXArray instance ( array ) SFXArray<SInt64Ptr> ar64; // oK SFXArray<SFXAnsiStringPtr> arstr;// oK
| Constructor/Destructor |
|---|
|
SFXArray( Void ) Constructor of SFXArray class.
|
|
SFXArray(
UInt16 threshold
, UInt16 cluster
) Constructor of SFXArray class.
|
| Public Functions | |
|---|---|
| SFCError |
Append(
V value
) Append( SFXArray< V > const & collection ) [DEPRECATED] Append an element.
|
| Void |
Clear( Void ) Clear the array.
|
| Bool |
Contains(
V value
) Check whether the value is contained or not.
|
| static SFXArray< V > const & |
EmptyInstance( Void ) Get an empty array.
|
| Bool |
Equals(
SFXArray< V > const & collection
) Check whether to equal the specified array or not.
|
| SInt32 |
FirstIndexOf(
V value
, SInt32 index = SINT32_MINIMUM
) Get the first index of the element to match with the specified value, searching from the beginning.
|
| V |
Get(
SInt32 index
) Get an element.
|
| UInt16 |
GetCluster( Void ) Get the cluster size of internal buffer memory.
|
| Enumerator |
GetEnumerator(
SInt32 index
) Get an enumerator.
|
| V |
GetFirst( Void ) Get the first element.
|
| Enumerator |
GetFirstEnumerator( Void ) Get the enumerator that points to the first element.
|
| Iterator |
GetFirstIterator( Void ) Get the iterator that points to the first element.
|
| Iterator |
GetIterator(
SInt32 index
) Get an iterator.
|
| V |
GetLast( Void ) Get the last element.
|
| Enumerator |
GetLastEnumerator( Void ) Get the enumerator that points to the last element.
|
| Iterator |
GetLastIterator( Void ) Get the iterator that points to the last element.
|
| SInt32 |
GetSize( Void ) Get the size(the number of elements).
|
| UInt16 |
GetThreshold( Void ) Get the minimum value of internal buffer size.
|
| SFCError |
Insert(
SInt32 index
, V value
) Insert( SInt32 index , SFXArray< V > const & collection ) Insert an element.
|
| SFCError |
InsertFirst(
SFXArray< V > const & collection
) InsertFirst( V value ) Insert an element at the beginning.
|
| SFCError |
InsertLast(
SFXArray< V > const & collection
) InsertLast( V value ) Insert an element at the end.
|
| Bool |
IsEmpty( Void ) Check whether the array is empty or not.
|
| SInt32 |
LastIndexOf(
V value
, SInt32 index = SINT32_MAXIMUM
) Get the last index of the element to match with the specified value, searching from the end.
|
| Void |
Remove(
SInt32 index
) Remove( SInt32 begin , SInt32 end ) Remove the elements at the specified index or range.
|
| Void |
RemoveFirst( Void ) Remove the first element.
|
| Void |
RemoveLast( Void ) Remove the last element.
|
| SFCError |
Set(
SFXArray< V > const & collection
) Set( SInt32 index , V value ) Set a value to the element. Or set an array.
|
| Void |
SetCluster(
UInt16 size
) Set the cluster size of internal buffer memory.
|
| SFCError |
SetFirst(
V value
) Set a value to the first element.
|
| SFCError |
SetLast(
V value
) Set a value to the last element.
|
| SFCError |
SetSize(
SInt32 size
) Set the size of array.( Set the number of elements )
|
| Void |
SetThreshold(
UInt16 size
) Set the minimum value of internal buffer size.
|
| V & |
operator[](
SInt32 index
) Get the element by index.
|
| V const & |
operator[](
SInt32 index
) Get the element by index.
|
| Types |
|---|
|
DefaultEnum Default values of minimun heap size and cluster size used inside the array.
|
|
Enumerator
Class for managing an enumerator.
|
|
Iterator
Class for managing an iterator.
|
[ public, explicit ] SFXArray(Void);
[ public, explicit ]
SFXArray(
UInt16 threshold // minimum value of buffer size
UInt16 cluster // cluster size
);
When constructing an array, if you can guess the number of its elements, you should specify its initial size in order to improve performance. Because memory reallocation can be avoided.
[ public ] SFCError Append( V value // element to append );
[ public ] SFCError Append( SFXArray< V > const & collection // array to append );
Append an element at the end of array. This function is deprecated, use InsertLast function.
SFXArray<SInt16> array; SInt16 i; // append an element if (array.Append(2) == SFERR_NO_ERROR) { // append an element if (array.Append(5) == SFERR_NO_ERROR) { // enumerate by index for (i = 0; i < array.GetSize(); ++i) { TRACE("%d", array[i]); // 2 5 } } }
SFXArray::Insert | SFXArray::InsertLast | SFXArray::Get | SFXArray::Remove | SFXArray::Set
[ public ] Void Clear(Void);
If the type of element is a pointer to a class instance, the instance is not released automatically.
SFXArray<SInt16> array;
...
array.Clear(); // release all the data and memory for management
[ public, const ] Bool Contains( V value // value to check );
If the type of element is a pointer to a class instance, its address is compared with.
SFXArray<SInt16> array; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // check whether the element is contained or not TRACE("Contains(2) = %s", (array.Contains(2)) ? ("true") : ("false")); // contains(2) = true TRACE("Contains(4) = %s", (array.Contains(4)) ? ("true") : ("false")); // contains(4) = false } }
[ public, static ] SFXArray< V > const & EmptyInstance(Void);
Get an instance that represents an empty array.
[ public, const ] Bool Equals( SFXArray< V > const & collection // array to compare with );
Check about two arrays whether the same element is saved in the same order or not.
If the type of element is a pointer to a class instance, its address is compared.
[ public, const ] SInt32 FirstIndexOf( V value // value to match with SInt32 index = SINT32_MINIMUM // starting index to search from );
Search from beginning to end, and get the first index of the element to match with the specified value.
By specifying a starting index, you can search from any position other than the beginning. (The origin index is 0.)
If the type of element is a pointer to a class instance, its address is compared.
SFXArray<SInt16> array; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // get the first index of the element matching with the specified value, searching from the beginning TRACE("FirstIndexOf(1) = %d", array.FirstIndexOf(1)); // firstIndexOf(1) = -1 TRACE("FirstIndexOf(2) = %d", array.FirstIndexOf(2)); // firstIndexOf(2) = 0 TRACE("FirstIndexOf(5) = %d", array.FirstIndexOf(5)); // firstIndexOf(5) = 1 } }
[ public, const ]
V Get(
SInt32 index // index of the element to get
);SFXArray::GetFirst | SFXArray::GetLast | SFXArray::Insert | SFXArray::Remove | SFXArray::Set
[ public, const ] UInt16 GetCluster(Void);
[ public, const ]
Enumerator GetEnumerator(
SInt32 index // index to start
);[ public, const ] V GetFirst(Void);
[ public, const ] Enumerator GetFirstEnumerator(Void);
SFXArray<SInt16> array; SFXArray<SInt16>::Enumerator en; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // get the enumerator that points to the first element en = array.GetFirstEnumerator(); // check whether the next element exists or not while(en.HasNext()) { TRACE("%d", en.GetNext()); // 2 5 } } }
[ public ] Iterator GetFirstIterator(Void);
SFXArray<SInt16> array; SFXArray<SInt16>::Iterator it; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // get the iterator that points to the first element it = array.GetFirstIterator(); // check whether the next element exists or not while(it.HasNext()) { TRACE("%d", it.GetNext()); // 2 5 } } }
[ public ]
Iterator GetIterator(
SInt32 index // index to start
);[ public, const ] V GetLast(Void);
[ public, const ] Enumerator GetLastEnumerator(Void);
[ public ] Iterator GetLastIterator(Void);
[ public, const ] SInt32 GetSize(Void);
SFXArray<SInt16> array; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // display the size(the number of elements) TRACE("%d",array.GetSize()); // 2 } }
[ public, const ] UInt16 GetThreshold(Void);
[ public ] SFCError Insert( SInt32 index // index to insert V value // value of the element to insert );
[ public ] SFCError Insert( SInt32 index // index to insert SFXArray< V > const & collection // array to insert );
Insert an element before the specified index.
If the specified index is invalid, the element is inserted at the valid position automatically.
SFXArray<SInt16> array; SInt16 i; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // insert an element at the first index if (array.Insert(0, 3) == SFERR_NO_ERROR) { // insert an element // if the specified index is invalid, the element is inserted at the valid position automatically if (array.Insert(10, 4) == SFERR_NO_ERROR) { // enumerate elements by index for (i = 0; i < array.GetSize(); ++i) { TRACE("%d", array[i]); // 3 2 5 4 } } } } }
SFXArray::Get | SFXArray::InsertFirst | SFXArray::InsertLast | SFXArray::Remove | SFXArray::Set
[ public ] SFCError InsertFirst( SFXArray< V > const & collection // array to insert );
[ public ] SFCError InsertFirst( V value // value of the element to insert );
[ public ] SFCError InsertLast( SFXArray< V > const & collection // array to insert );
[ public ] SFCError InsertLast( V value // value of the element to insert );
[ public, const ] Bool IsEmpty(Void);
[ public, const ] SInt32 LastIndexOf( V value // value to match with SInt32 index = SINT32_MAXIMUM // starting index to search from );
Search from end to beginning, and get the last index of the element to match with the specified value.
By specifying a starting index, you can search from any position other than the end. (The origin index is 0.)
If the type of element is a pointer to a class instance, its address is compared.
SFXArray<SInt16> array; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // get the last index of the element matching with the specified value, searching from the end TRACE("LastIndexOf(1) = %d", array.LastIndexOf(1)); // lastIndexOf(1) = -1 TRACE("LastIndexOf(2) = %d", array.LastIndexOf(2)); // lastIndexOf(2) = 0 TRACE("LastIndexOf(5) = %d", array.LastIndexOf(5)); // lastIndexOf(5) = 1 } }
[ public ] Void Remove( SInt32 index // index to remove );
[ public ] Void Remove( SInt32 begin // beginning index to remove SInt32 end // end index to remove );
SFXArray<SInt16> array; SInt16 i; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // insert an element at the beginning index if (array.Insert(0, 3) == SFERR_NO_ERROR) { // insert an element // if the specified index is invalid, the element is inserted at the valid position automatically if (array.Insert(10, 4) == SFERR_NO_ERROR) { // remove from array[1] to array[2] array.Remove(1, 3); // enumerate elements by index for (i = 0; i < array.GetSize(); ++i) { TRACE("%d", array[i]); // 3 4 } } } } }
[ public ] Void RemoveFirst(Void);
[ public ] Void RemoveLast(Void);
[ public ] SFCError Set( SFXArray< V > const & collection // array to set );
[ public ] SFCError Set( SInt32 index // index to set V value // value to set );
SFXArray<SInt16> array; SInt16 i; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // set a value to the element of array if (array.Set(1, 10) == SFERR_NO_ERROR) { // enumerate elements by index for (i = 0; i < array.GetSize(); ++i) { TRACE("%d", array[i]); // 2 10 } } } }
[ public ] SFCError SetFirst( V value // value to set );
[ public ] SFCError SetLast( V value // value to set );
If the specified size is smaller than the size of current array, elements after the specified size are removed.
[ public ]
V & operator[](
SInt32 index // index of element to get
);
[ public, const ]
V const & operator[](
SInt32 index // index of element to get
);
enum DefaultEnum {
DEFAULT_THRESHOLD = 4 * sizeof(VoidPtr), // default value of minimum heap size
DEFAULT_CLUSTER = 8 * sizeof(VoidPtr) // default value of cluster size
};
SFXArray::DefaultEnum has default values of minimun heap size and cluster size used inside the SFXArray class.
Concretely, they are set as follows.
[ public ]
SFMTYPEDEFCLASS(Enumerator)
friend class Enumerator;
class Enumerator {
public:
explicit Enumerator (Void) : Enumeratoa();
Enumerator (IteratorConstRef iterator) : Enumeratoa(iterator);
EnumeratorRef operator= (IteratorConstRef iterator);
V GetNext (Void);
V GetPrevious (Void);
Bool HasNext (Void) const;
Bool HasPrevious (Void) const;
Bool IsValid (Void) const;
};
The Enumerator class is a class that manages an enumerator.
The Enumerator class has the following member functions.
| GetNext | Get the next element. If no next element, return null. |
| GetPrevious | Get the previous element. If no previous element, return null. |
| HasNext | Check whether the next element exists or not. |
| HasPrevious | Check whether the previous element exists or not. |
| IsValid | Check whether the enumerator is valid or not. |
SFXArray<SInt16> array; SFXArray<SInt16>::Enumerator en; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // get the enumerator that points to the first element en = array.GetFirstEnumerator(); // check whether the next element exists or not while(en.HasNext()) { TRACE("%d", en.GetNext()); // 2 5 } }
[ public ]
SFMTYPEDEFCLASS(Iterator)
friend class Iterator;
class Iterator {
public:
explicit Iterator (Void) : Iteratoa();
SFCError Set (V value);
V GetNext (Void);
V GetPrevious (Void);
Bool HasNext (Void) const;
Bool HasPrevious (Void) const;
Bool IsValid (Void) const;
SFCError Insert (V value);
Vold Remove (Void);
friend class Enumerator;
};
The Iterator class is a class that manages an iterator.
The Iterator class has the following member functions.
| Set | Set a value to the element of current iterator. |
| GetNext | Get the next element. If no next element, return null. |
| GetPrevious | Get the previous element. If no previous element, return null. |
| HasNext | Check whether the next element exists or not. |
| HasPrevious | Check whether the previous element exists or not. |
| IsValid | Check whether the iterator is valid or not. |
| Insert | Insert an element after the element of current iterator. |
| Remove | Remove the element of current iterator. |
SFXArray<SInt16> array; SFXArray<SInt16>::Iterator it; // append an element if (array.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (array.InsertLast(5) == SFERR_NO_ERROR) { // get the iterator that points to the first element it = array.GetFirstIterator(); // check whether the next element exists or not while(it.HasNext()) { TRACE("%d", it.GetNext()); // 2 5 } } }
|
Copyright (C) 2002 - 2009 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|