SophiaFramework UNIVERSE 5.3 |
SFXStack is the data structure to store all its elements into the consecutive memory area(internal buffer) in which the last added element is removed first.
In the default settings, when the first element is inserted, the internal buffer will be allocated by the size set with the SFXStack::SetThreshold function(default: size for 4 elements). Then, in case memory becomes insufficient while elements are inserted one by one, the internal buffer will be expanded by the cluster size set with the SFXStack::SetCluster function(default: size for 8 elements). Here, the size of one element is 4 byte.
Caution | |
---|---|
When the internal buffer is expanded, new consecutive memory area bigger than the current one by the cluster size will be allocated and all data of existing elements will be copied there. Therefore, if expansion is performed frequently, it may become the cause of performance deterioration If the number of the elements are known in advance, it is recommended to set the internal buffer size with the SFXStack::SetThreshold / SFXStack::SetCluster functions or to set the number of the elements with the SFXStack::SetSize function(*). * If the internal buffer is expanded with the SFXStack::SetSize function, each element in the expanded area will be set to 0. |
Each element size of SFXStack needs to be less than or equal 4 byte. In order to process data more than 4 byte ( such as UInt64 type, Float64 type, and so on ) or class instance as an element of the SFXStack instance ( stack ), a pointer should be used.
// data more than 4 byte or class instance cannot be an element of the SFXStack instance ( stack ) // SFXStack<SInt64> st64; NG // SFXStack<SFXAnsiString> ststr; NG // but a pointer to the data more than 4 byte or class instance can be an element of the SFXStack instance ( stack ) SFXStack<SInt64Ptr> st64; // OK SFXStack<SFXAnsiStringPtr> ststr;// OK
Constructor/Destructor |
---|
SFXStack( Void ) Constructor of the SFXStack class.
|
SFXStack(
UInt16 threshold
, UInt16 cluster
) Constructor of the SFXStack class.
|
Public Functions | |
---|---|
SFCError |
Append(
SFXStack< V > const & collection
) [DEPRECATED] Append an element.
|
SFCError |
Append(
V value
) [DEPRECATED] Append an element.
|
Void |
Clear( Void ) Clear this stack.
|
Bool |
Contains(
V value
) Check whether or not this stack contains the specified value.
|
static SFXStack< V > const & |
EmptyInstance( Void ) Get an empty stack.
|
Bool |
Equals(
SFXStack< V > const & collection
) Check whether or not this stack equals the specified stack.
|
SInt32 |
FirstIndexOf(
V value
, SInt32 index = SINT32_MINIMUM
) Get the first index of the element that equals the specified value, searching from the head.
|
V |
Get(
SInt32 index
) Get the element at the specified index.
|
UInt16 |
GetCluster( Void ) Get the cluster size of the internal buffer memory. [in bytes]
|
Enumerator |
GetEnumerator(
SInt32 index
) Get the enumerator that points to the element at the specified index.
|
V |
GetFirst( Void ) Get the element at the head.
|
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 the iterator that points to the element at the specified index.
|
V |
GetLast( Void ) Get the element at the tail.
|
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 the elements).
|
UInt16 |
GetThreshold( Void ) Get the minimum size of the internal buffer memory. [in bytes]
|
SFCError |
Insert(
SInt32 index
, SFXStack< V > const & collection
) Insert the specified element or stack before the specified index.
|
SFCError |
Insert(
SInt32 index
, V value
) Insert the specified element or stack before the specified index.
|
SFCError |
InsertFirst(
SFXStack< V > const & collection
) Insert the specified element or stack at the head.
|
SFCError |
InsertFirst(
V value
) Insert the specified element or stack at the head.
|
SFCError |
InsertLast(
SFXStack< V > const & collection
) Insert the specified element or stack at the tail.
|
SFCError |
InsertLast(
V value
) Insert the specified element or stack at the tail.
|
Bool |
IsEmpty( Void ) Check whether or not this stack is empty.
|
SInt32 |
LastIndexOf(
V value
, SInt32 index = SINT32_MAXIMUM
) Get the last index of the element that equals the specified value, searching from the tail.
|
SFCError |
Move(
SInt32 destination
, SInt32 source
) Move the element at the specified index to the specified index.
|
SFCError |
MoveFirst(
SInt32 source
) Move the element at the specified index to the head.
|
SFCError |
MoveLast(
SInt32 source
) Move the element at the specified index to the tail.
|
V |
Peek( Void ) Get the top element from this stack.
|
V |
Pop( Void ) Get the top element of this stack and remove it.
|
SFCError |
Push(
V value
) Append an element onto the stack.
|
Void |
Remove(
SInt32 index
) Remove the elements at the specified index or range.
|
Void |
Remove(
SInt32 begin
, SInt32 end
) Remove the elements at the specified index or range.
|
Void |
RemoveFirst( Void ) Remove the element at the head.
|
Void |
RemoveLast( Void ) Remove the element at the tail.
|
SInt32 |
Search(
V value
) Get the index of the element that equals the specified value, searching from the top.
|
SFCError |
Set(
SFXStack< V > const & collection
)
Set the element at the specified index of this stack to the specified value.
Or set this stack to the specified stack.
|
SFCError |
Set(
SInt32 index
, V value
)
Set the element at the specified index of this stack to the specified value.
Or set this stack to the specified stack.
|
Void |
SetCluster(
UInt16 size
) Set the cluster size of the internal buffer memory. [in bytes]
|
SFCError |
SetFirst(
V value
) Set the element at the head to the specified value.
|
SFCError |
SetLast(
V value
) Set the element at the tail to the specified value.
|
SFCError |
SetSize(
SInt32 size
) Set the size of this stack to the specified value.
|
Void |
SetThreshold(
UInt16 size
) Set the minimum size of the internal buffer memory. [in bytes]
|
SFCError |
Swap(
SInt32 destination
, SInt32 source
) Swap two elements at the specified indexes.
|
SFCError |
SwapFirst(
SInt32 source
) Swap the element at the specified index for the element at the head.
|
SFCError |
SwapLast(
SInt32 source
) Swap the element at the specified index for the element at the tail.
|
V & |
operator[](
SInt32 index
) Get the element by index.
|
V const & |
operator[](
SInt32 index
) Get the element by index.
|
Types |
---|
DefaultEnum Constants that represent the default values for the minimum size and the cluster size of the internal buffer memory. [in bytes]
|
Enumerator Class for managing the enumerator of this stack.
|
Iterator Class for managing the iterator of this stack.
|
[ public, explicit ] SFXStack(Void);
[ public, explicit ] SFXStack( UInt16 threshold // minimum size of the internal buffer memory UInt16 cluster // cluster size );
It is possible to improve performance by specifying the minimum size of the internal buffer memory and the cluster size optimized for your application in order to minimize the occurrence of memory reallocation.
Tip | |
---|---|
The minimum size of the internal buffer memory or the cluster size can be set with the SFXStack::SetThreshold or SFXStack::SetCluster function. |
SFXStack::Set | SFXStack::SetThreshold | SFXStack::SetCluster
[ public ] SFCError Append( SFXStack< V > const & collection // stack to append );
[ public ] SFCError Append( V value // element to append );
Append an element at the end of stack. This function is deprecated, use the SFXStack::InsertLast function.
SFXStack<SInt08> stack; SInt16 i; // append an element if (stack.Append(2) == SFERR_NO_ERROR) { // append an element if (stack.Append(5) == SFERR_NO_ERROR) { // enumerate by index for (i = 0; i < stack.GetSize(); ++i) { TRACE("%d", stack[i]); // 2 5 } } }
SFXStack::Insert | SFXStack::InsertLast | SFXStack::Get | SFXStack::Push | SFXStack::Remove | SFXStack::Set
[ public ] Void Clear(Void);
This function clears this stack. All the internal buffer allocated to this stack will be released.
After this function is executed, the size of this stack will become 0.
Caution | |
---|---|
If the type of the element is a pointer to a class instance or data bigger than 4 bytes, memory area that the pointer points to will not be released automatically. Before clearing this stack, it is necessary to release that area explicitly using the delete statement. Otherwise, memory leakage will occur. |
Note | |
---|---|
This function will be called automatically when this stack goes out of scope. |
SFXStack<SInt08> stack;
...
stack.Clear(); // clear the stack
SFXStack::Remove | SFXStack::SetCluster | SFXStack::SetThreshold | SFXStack::GetSize
[ public, const ] Bool Contains( V value // value to check );
This function checks whether or not this stack contains the specified value.
Note | |
---|---|
If the type of the element is a pointer to a class instance or data bigger than 4 bytes, their addresses will be compared with. |
SFXStack<SInt08> stack; // push an element if (stack.Push(2) == SFERR_NO_ERROR) { // push an element if (stack.InsertLast(5) == SFERR_NO_ERROR) { // check whether or not the stack contains the elements below TRACE("Contains(2) = %s", (stack.Contains(2)) ? ("true") : ("false")); // contains(2) = true TRACE("Contains(4) = %s", (stack.Contains(4)) ? ("true") : ("false")); // contains(4) = false } }
[ public, static ] SFXStack< V > const & EmptyInstance(Void);
Get an instance that represents an empty stack.
[ public, const ] Bool Equals( SFXStack< V > const & collection // stack to compare with );
This function checks whether or not this stack equals the specified stack (whether or not the same elements are saved in the same order).
Note | |
---|---|
If the type of the element is a pointer, its address will be compared. |
[ public, const ] SInt32 FirstIndexOf( V value // value to search SInt32 index = SINT32_MINIMUM // index to search from );
This function gets the first index of the element of this stack that equals the specified value, searching from the head to the tail.
By specifying the beginning index in the argument, you can search from any position other than the head. (The index of the head is 0.)
Note | |
---|---|
If the type of the element is a pointer, its address will be compared. |
SFXStack<SInt08> stack; // push an element onto the stack if (stack.Push(2) == SFERR_NO_ERROR) { // push an element onto the stack if (stack.Push(5) == SFERR_NO_ERROR) { // get the first index of the element that equals the specified value, searching from the head to the tail TRACE("FirstIndexOf(1) = %d", stack.FirstIndexOf(1)); // firstIndexOf(1) = -1 TRACE("FirstIndexOf(2) = %d", stack.FirstIndexOf(2)); // firstIndexOf(2) = 0 TRACE("FirstIndexOf(5) = %d", stack.FirstIndexOf(5)); // firstIndexOf(5) = 1 } }
[ public, const ] V Get( SInt32 index // index of the element to get );
Element at the index specified in the argument. 0 or null will be returned if no element exists at the specified index.
This function gets the element at the index specified in the argument.
Caution | |
---|---|
In case no element exists at the specified index, no error will occur but this function will return 0 or null. |
SFXStack::GetFirst | SFXStack::GetLast | SFXStack::Insert | SFXStack::Remove | SFXStack::Set
[ public, const ] UInt16 GetCluster(Void);
Cluster size of the internal buffer memory [in bytes]
This function gets the cluster size, by which the size of the internal buffer memory increases. [in bytes]
[ public, const ] Enumerator GetEnumerator( SInt32 index // index to start );
Enumerator that points to the element at the specified index
This function gets the enumerator of this stack that points to the element at the specified index.
Note | |
---|---|
If the specified index is less than or equals 0, this function is same as the SFXStack::GetFirstEnumerator function. If the specified index is more than or equals the size of this stack, this function is same as the SFXStack::GetLastEnumerator function. |
SFXStack::GetFirstEnumerator | SFXStack::GetLastEnumerator | SFXStack::GetIterator | SFXStack::Enumerator
[ public, const ] V GetFirst(Void);
Element at the head. 0 or null will be returned if no element exists in this stack.
This function gets the element at the head.
Caution | |
---|---|
In case no element exists in this stack, no error will occur but this function will return 0 or null. |
SFXStack::Get | SFXStack::GetLast | SFXStack::InsertFirst | SFXStack::RemoveFirst
[ public, const ] Enumerator GetFirstEnumerator(Void);
Enumerator that points to the first element
This function gets the enumerator of this stack that points to the first element.
SFXStack<SInt08> stack; SFXStack<SInt08>::Enumerator en; // append an element if (stack.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (stack.InsertLast(5) == SFERR_NO_ERROR) { // get the enumerator that points to the first element en = stack.GetFirstEnumerator(); // check whether the next element exists or not while(en.HasNext()) { TRACE("%d", en.GetNext()); // 2 5 } } }
[ public ] Iterator GetFirstIterator(Void);
Iterator that points to the first element
This function gets the iterator of this stack that points to the first element.
SFXStack<SInt08> stack; SFXStack<SInt08>::Iterator it; // append an element if (stack.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (stack.InsertLast(5) == SFERR_NO_ERROR) { // get the iterator that points to the first element it = stack.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 );
Iterator that points to the element at the specified index
This function gets the iterator of this stack that points to the element at the specified index.
Note | |
---|---|
If the specified index is less than or equals 0, this function is same as the SFXStack::GetFirstIterator function. If the specified index is more than or equals the size of this stack, this function is same as the SFXStack::GetLastIterator function. |
SFXStack::GetFirstIterator | SFXStack::GetLastIterator | SFXStack::GetEnumerator | SFXStack::Iterator
[ public, const ] V GetLast(Void);
Element at the tail. 0 or null will be returned if no element exists in this stack.
This function gets the element at the tail.
Caution | |
---|---|
In case no element exists in this stack, no error will occur but this function will return 0 or null. |
SFXStack::Get | SFXStack::GetFirst | SFXStack::Peek | SFXStack::InsertLast | SFXStack::RemoveLast
[ public, const ] Enumerator GetLastEnumerator(Void);
Enumerator that points to the last element
This function gets the enumerator of this stack that points to the last element.
[ public ] Iterator GetLastIterator(Void);
Iterator that points to the last element
This function gets the iterator of this stack that points to the last element.
[ public, const ] SInt32 GetSize(Void);
SFXStack<SInt08> stack; SInt16 i; // append an element if (stack.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (stack.InsertLast(5) == SFERR_NO_ERROR) { // display the size(the number of the elements) TRACE("%d", stack.GetSize()); // 2 } }
[ public, const ] UInt16 GetThreshold(Void);
Minimum size of the internal buffer memory. [in bytes]
This function gets the minimum size of the internal buffer memory. [in bytes]
[ public ] SFCError Insert( SInt32 index // index to insert SFXStack< V > const & collection // stack to insert );
[ public ] SFCError Insert( SInt32 index // index to insert V value // value of the element to insert );
This function inserts the specified element or stack before the specified index.
If the value of the specified index is less than or equals 0, the element will be inserted at the head.
If the value of the specified index is greater than or equals the number of the elements, the element will be inserted at the tail.
SFXStack<SInt08> stack; SInt16 i; // insert an element at the tail if (stack.InsertLast(2) == SFERR_NO_ERROR) { // insert an element at the tail if (stack.InsertLast(5) == SFERR_NO_ERROR) { // insert an element at the head if (stack.Insert(0, 3) == SFERR_NO_ERROR) { // insert an element before the specified index // if the value of the specified index is less than or equals 0, an element will be inserted at head // if the value of the specified index is greater than or equals the number of the elements, an element will be inserted at the tail if (stack.Insert(10, 4) == SFERR_NO_ERROR) { // remove from stack[1] to stack[2] stack.Remove(1, 3); // enumerate elements by index for (i = 0; i < stack.GetSize(); ++i) { TRACE("%d", stack[i]); // 3 4 } } } } }
SFXStack::InsertFirst | SFXStack::InsertLast | SFXStack::Set | SFXStack::Get | SFXStack::Remove
[ public ] SFCError InsertFirst( SFXStack< V > const & collection // stack to insert );
[ public ] SFCError InsertFirst( V value // value of the element to insert );
This function the specified element or stack at the head.
SFXStack::Insert | SFXStack::InsertLast | SFXStack::RemoveFirst | SFXStack::GetFirst
[ public ] SFCError InsertLast( SFXStack< V > const & collection // stack to insert );
[ public ] SFCError InsertLast( V value // value of the element to insert );
This function inserts the specified element or stack at the tail.
SFXStack::Insert | SFXStack::InsertFirst | SFXStack::Push | SFXStack::GetLast | SFXStack::RemoveLast
[ public, const ] Bool IsEmpty(Void);
This function checks whether or not this stack is empty.
[ public, const ] SInt32 LastIndexOf( V value // value to search SInt32 index = SINT32_MAXIMUM // index to search from );
This function gets the last index of the element of this stack that equals the specified value, searching from the tail to the head.
By specifying the beginning index in the argument, you can search from any position other than the tail. (The index of the head is 0.)
Note | |
---|---|
If the type of the element is a pointer, its address will be compared. |
SFXStack<SInt08> stack; // push an element onto the stack if (stack.Push(2) == SFERR_NO_ERROR) { // push an element onto the stack if (stack.Push(5) == SFERR_NO_ERROR) { // get the last index of the element that equals the specified value, searching from the tail to the head TRACE("LastIndexOf(1) = %d", stack.LastIndexOf(1)); // lastIndexOf(1) = -1 TRACE("LastIndexOf(2) = %d", stack.LastIndexOf(2)); // lastIndexOf(2) = 0 TRACE("LastIndexOf(5) = %d", stack.LastIndexOf(5)); // lastIndexOf(5) = 1 } }
SFXStack::Contains | SFXStack::FirstIndexOf | SFXStack::Search
[ public ] SFCError Move( SInt32 destination // destination index of the element to move SInt32 source // source index of the element to move );
This function moves the element at the specified index to the specified index.
This function moves the element at the specified index to the head.
This function moves the element at the specified index to the tail.
[ public, const ] V Peek(Void);
Top element of this stack (Last pushed element)
This function gets the the top element from this stack, which is the last pushed element.
Caution | |
---|---|
If this stack is empty, no error will occur, and 0 or null will be returned depending on the type of the element. |
Note | |
---|---|
After this function is executed, the contents of this stack will remain the same as before. |
SFXStack<SInt08> stack; // push an element onto the stack if (stack.Push(1) == SFERR_NO_ERROR) { // get the top element from the stack TRACE("%d", stack.Peek()); // 1 // push an element onto the stack if (stack.Push(2) == SFERR_NO_ERROR) { // get the top element from the stack TRACE("%d", stack.Peek()); // 2 // push an element onto the stack if (stack.Push(3) == SFERR_NO_ERROR) { // get the top element from the stack TRACE("%d", stack.Peek()); // 3 } } }
SFXStack::Push | SFXStack::Pop | SFXStack::Get | SFXStack::GetFirst | SFXStack::GetLast
[ public ] V Pop(Void);
Top element of this stack. If this stack is empty, no error will occur and 0 will be returned.
This function gets the top element of this stack and remove it.
Caution | |
---|---|
If this stack is empty, no error will occur, and 0 or null will be returned depending on the type of the element. |
SFXStack<SInt08> stack; // append an element onto the stack if (stack.Push(1) == SFERR_NO_ERROR) { // append an element onto the stack if (stack.Push(2) == SFERR_NO_ERROR) { // append an element onto the stack if (stack.Push(3) == SFERR_NO_ERROR) { // get the top element of stack and remove it TRACE("%d", stack.Pop()); // 3 TRACE("%d", stack.Pop()); // 2 TRACE("%d", stack.Pop()); // 1 } } }
SFXStack::Peek | SFXStack::Push| SFXStack::IsEmpty | SFXStack::Get | SFXStack::GetFirst | SFXStack::GetLast | SFXStack::Remove | SFXStack::RemoveFirst | SFXStack::RemoveLast
[ public ] SFCError Push( V value // element to append(push) );
Inside the Push function, the SFXStack::InsertLast function is called.
SFXStack<SInt08> stack; // append an element onto the stack if (stack.Push(1) == SFERR_NO_ERROR) { // get the top element of stack, but don't remove it TRACE("%d", stack.Peek()); // 1 // append an element onto the stack if (stack.Push(2) == SFERR_NO_ERROR) { // get the top element of stack, but don't remove it TRACE("%d", stack.Peek()); // 2 // append an element onto the stack if (stack.Push(3) == SFERR_NO_ERROR) { // get the top element of stack, but don't remove it TRACE("%d", stack.Peek()); // 3 } } }
SFXStack::Insert | SFXStack::InsertLast | SFXStack::Set | SFXStack::Pop | SFXStack::Peek
[ public ] Void Remove( SInt32 index // index of the element to remove );
[ public ] Void Remove( SInt32 begin // beginning index(this index is included) SInt32 end // ending index(this index is not included) );
This function removes the element at the specified index or the elements in the specified index range.
If the specified index is less than 0 or greater than or equals the number of the elements, no element will be removed.
If the beginning index to remove is greater than or equals the number of the elements or the ending index to remove is less than or equals 0, no element will be removed.
If the beginning index to remove is less than or equals 0, it will be reset to 0.
If the ending index to remove is greater than the number of the elements, it will be reset to the number of the elements.
Caution | |
---|---|
If no element exists at the specified index or range, no error will occur and nothing will happen. |
SFXStack<SInt08> stack; SInt16 i; // insert an element at the tail if (stack.InsertLast(2) == SFERR_NO_ERROR) { // insert an element at the tail if (stack.InsertLast(5) == SFERR_NO_ERROR) { // insert an element at the head if (stack.Insert(0, 3) == SFERR_NO_ERROR) { // insert an element before the specified index // if the value of the specified index is less than or equals 0, an element will be inserted at head // if the value of the specified index is greater than or equals the number of the elements, an element will be inserted at the tail if (stack.Insert(10, 4) == SFERR_NO_ERROR) { // remove from stack[1] to stack[2] stack.Remove(1, 3); // enumerate elements by index for (i = 0; i < stack.GetSize(); ++i) { TRACE("%d", stack[i]); // 3 4 } } } } }
SFXStack::RemoveFirst | SFXStack::RemoveLast | SFXStack::Insert | SFXStack::Get | SFXStack::Set
[ public ] Void RemoveFirst(Void);
This function removes the element at the head.
Caution | |
---|---|
If no element exists in this stack, no error will occur and nothing will happen. |
SFXStack::Remove | SFXStack::RemoveLast | SFXStack::GetFirst | SFXStack::InsertFirst
[ public ] Void RemoveLast(Void);
This function removes the element at the tail.
Caution | |
---|---|
If no element exists in this stack, no error will occur and nothing will happen. |
SFXStack::Remove | SFXStack::RemoveFirst | SFXStack::GetLast | SFXStack::InsertLast | SFXStack::Pop
[ public, const ] SInt32 Search( V value // value of the element to search for );
This function gets the first index of the element of this stack that equals the specified value, searching from the top of this stack. (The index of the top is 1.)
Note | |
---|---|
If the type of the element is a pointer, its address will be compared. |
SFXStack<SInt08> stack; // append an element onto the stack if (stack.Push(1) == SFERR_NO_ERROR) { // append an element onto the stack if (stack.Push(2) == SFERR_NO_ERROR) { // append an element onto the stack if (stack.Push(3) == SFERR_NO_ERROR) { // search from the top of stack TRACE("Search(3) = %d", stack.Search(3)); // 1 TRACE("Search(5) = %d", stack.Search(5)); // -1 } } }
SFXStack::Contains | SFXStack::FirstIndexOf | SFXStack::LastIndexOf
[ public ] SFCError Set( SFXStack< V > const & collection // stack to set );
[ public ] SFCError Set( SInt32 index // index to set V value // value of the element to set );
This function sets the element at the specified index of this stack to the specified value, or sets this stack to the specified stack.
* In case an error occurs during processing, this stack will be restored.
SFXStack<SInt08> stack; SInt16 i; // append an element if (stack.Push(2) == SFERR_NO_ERROR) { // append an element if (stack.Push(5) == SFERR_NO_ERROR) { // set a value to the element if (stack.Set(1, 10) == SFERR_NO_ERROR) { // enumerate elements by index for (i = 0; i < stack.GetSize(); ++i) { TRACE("%d", stack[i]); // 2 10 } } } }
SFXStack::Get | SFXStack::SetFirst | SFXStack::SetLast | SFXStack::Insert | SFXStack::Remove
This function sets the minimum unit to allocate the internal buffer memory(SFXClusterHeap). [in bytes]
Default: SFXStack::DEFAULT_CLUSTER bytes
For the value of SFXStack::DEFAULT_CLUSTER, refer to SFXStack::DefaultEnum.
Tip | |
---|---|
Since the size of one element is 4 byte, a multiple of four should be specified in the size argument. |
Internal buffer memory | |
---|---|
In the SFXStack class, an element will be stored into the internal buffer memory when appended. Initially, the size set with the SFXStack::SetThreshold function will be allocated as the internal buffer memory. If an element cannot be stored into the internal buffer memory when tried to be appended, the size added by the cluster size set with the SFXStack::SetCluster function will be re-allocated as the internal buffer memory. To minimize the re-allocation of the the internal buffer memory, it is recommended to optimize the size set with the SFXStack::SetThreshold / SFXStack::SetCluster function depending on the application characteristics. |
SFXStack::GetCluster | SFXStack::SetThreshold | SFXStack::DefaultEnum | SFXClusterHeap::SetCluster | SFXClusterHeap
[ public ] SFCError SetFirst( V value // value of the element to set );
This function sets the element at the head to the specified value.
[ public ] SFCError SetLast( V value // value of the element to set );
This function sets the element at the tail to the specified value.
This function sets the size of this stack to the specified value.
Note | |
---|---|
If the specified size is smaller than the current size of this stack, elements after the specified size will be removed. On the contrary, if it is bigger than the current size of this stack, each of the expanded elements will be set to 0. |
This function sets the minimum memory of the internal buffer memory(SFXClusterHeap). [in bytes]
Default: SFXStack::DEFAULT_THRESHOLD bytes
For the value of SFXStack::DEFAULT_THRESHOLD, refer to SFXStack::DefaultEnum.
Tip | |
---|---|
Since the size of one element is 4 byte, a multiple of four should be specified in the size argument. |
Internal buffer memory | |
---|---|
In the SFXStack class, an element will be stored into the internal buffer memory when appended. Initially, the size set with the SFXStack::SetThreshold function will be allocated as the internal buffer memory. If an element cannot be stored into the internal buffer memory when tried to be appended, the size added by the cluster size set with the SFXStack::SetCluster function will be re-allocated as the internal buffer memory. To minimize the re-allocation of the the internal buffer memory, it is recommended to optimize the size set with the SFXStack::SetThreshold / SFXStack::SetCluster function depending on the application characteristics. |
SFXStack::GetThreshold | SFXStack::SetCluster | SFXStack::DefaultEnum | SFXClusterHeap::SetThreshold | SFXClusterHeap
This function swaps two elements at the specified indexes.
This function swaps the element at the specified index for the element at the head.
This function swaps the element at the specified index for the element at the tail.
[ public ] V & operator[]( SInt32 index // index of the element to get );
[ public, const ] V const & operator[]( SInt32 index // index of the element to get );
enum DefaultEnum { DEFAULT_THRESHOLD = 4 * 4, // default minimum size of the internal buffer memory [in bytes] DEFAULT_CLUSTER = 8 * 4 // default cluster size to allocate the internal buffer memory [in bytes] };
DEFAULT_THRESHOLD and DEFAULT_CLUSTER are the constants that represent the default values for the minimum size and the cluster size of the internal buffer memory(SFXClusterHeap). [in bytes]
SFXStack::SetCluster | SFXStack::SetThreshold | SFXClusterHeap
[ public ] SFMTYPEDEFCLASS(Enumerator) friend class Enumerator; class Enumerator { public: explicit Enumerator (Void) : Enumeratoa(); Enumerator (IteratorConstRef iterator) : Enumeratox(iterator); EnumeratorRef operator= (IteratorConstRef iterator); V GetNext (Void); V GetPrevious (Void); Bool HasNext (Void) const; Bool HasPrevious (Void) const; Bool IsValid (Void) const; };
This class is for managing the enumerator of this stack.
This class has the following member functions.
GetNext | Get the next element. If no next element exists, null or 0 will be returned. |
GetPrevious | Get the previous element. If no previous element exists, null or 0 will be returned. |
HasNext | Check whether or not the next element exists. |
HasPrevious | Check whether or not the previous element exists. |
IsValid | Check whether or not the enumerator is valid. |
SFXStack<SInt08> stack; SFXStack<SInt08>::Enumerator en; // append an element if (stack.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (stack.InsertLast(5) == SFERR_NO_ERROR) { // get the enumerator that points to the first element en = stack.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); Void Remove (Void); friend class Enumerator; };
This class is for managing the iterator of this stack.
This class has the following member functions.
Set | Set the element of current iterator to the specified value. |
GetNext | Get the next element. If no next element exists, null or 0 will be returned. |
GetPrevious | Get the previous element. If no previous element exists, null or 0 will be returned. |
HasNext | Check whether or not the next element exists. |
HasPrevious | Check whether or not the previous element exists. |
IsValid | Check whether or not the iterator is valid. |
Insert | Insert an element after the element of current iterator. |
Remove | Remove the element of current iterator. |
SFXStack<SInt08> stack; SFXStack<SInt08>::Iterator it; // append an element if (stack.InsertLast(2) == SFERR_NO_ERROR) { // append an element if (stack.InsertLast(5) == SFERR_NO_ERROR) { // get the iterator that points to the first element it = stack.GetFirstIterator(); // check whether the next element exists or not while(it.HasNext()) { TRACE("%d", it.GetNext()); // 2 5 } } }
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |