PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1
SFXStack
Class that represents a stack.
#include <SFXStack.h.hpp>
class SFXStack;
SFMTYPEDEFCLASS(SFXStack)

Inheritance diagram

 Inheritance diagram of SFXStackClass

Collaboration diagram

 Collaboration diagram of SFXStackClass

Description

Each element of the SFXStack instance ( stack ) 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 SFXStack instance ( stack ), a pointer should be used.

// data more than 4 bytes 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 bytes or class instance can be an element of the SFXStack instance ( stack )

SFXStack<SInt64Ptr> st64;        // oK
SFXStack<SFXAnsiStringPtr> ststr;// oK

Reference

SFXArray | SFXList

Member

Constructor/Destructor
SFXStack( Void )
Constructor of SFXStack class.
SFXStack( UInt16 threshold , UInt16 cluster )
Constructor of SFXStack class.
Public Functions
SFCError Append( SFXStack< V > const & collection )
Append( V value )
[DEPRECATED] Append an element.
Void Clear( Void )
Clear the stack.
Bool Contains( V value )
Check whether the value is contained or not.
static
SFXStack< V > const &
EmptyInstance( Void )
Get an empty stack.
Bool Equals( SFXStack< V > const & collection )
Check whether to equal the specified stack or not.
SInt32 FirstIndexOf( V value , SInt32 index = SINT32_MINIMUM )
Get the first index of the element matching 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 , SFXStack< V > const & collection )
Insert( SInt32 index , V value )
Insert an element.
SFCError InsertFirst( SFXStack< V > const & collection )
InsertFirst( V value )
Insert an element at the beginning.
SFCError InsertLast( SFXStack< V > const & collection )
InsertLast( V value )
Insert an element at the end.
Bool IsEmpty( Void )
Check whether the stack is empty or not.
SInt32 LastIndexOf( V value , SInt32 index = SINT32_MAXIMUM )
Get the last index of the element matching with the specified value, searching from the end.
V Peek( Void )
Get the top element of stack, but don't remove it.
V Pop( Void )
Get the top element of stack and remove it.
SFCError Push( V value )
Append an element onto the stack.
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.
SInt32 Search( V value )
Get the index of element to match with the specified value, searching from the top of stack.
SFCError Set( SFXStack< V > const & collection )
Set( SInt32 index , V value )
Set a value to the element. Or set a stack.
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 stack. ( 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 stack.
Enumerator
Class for managing an enumerator.
Iterator
Class for managing an iterator.

SFXStack::SFXStack
Constructor of SFXStack class.
[ public, explicit ]
SFXStack(Void);
[ public, explicit ]
SFXStack(
    UInt16 threshold   // minimum value of buffer size
    UInt16 cluster     // cluster siz
);

SFXStack::Append
[DEPRECATED] Append an element.
[ public ]
SFCError Append(
    SFXStack< V > const & collection   // stack to append
);
[ public ]
SFCError Append(
    V value   // element to append
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMOERY
  • If failed : SFERR_FAILED

Description

Append an element at the end of stack. This function is deprecated, use InsertLast function.

Example

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 
        }
    }
}

Reference

SFXStack::Insert | SFXStack::InsertLast | SFXStack::Get | SFXStack::Push | SFXStack::Remove | SFXStack::Set


SFXStack::Clear
Clear the stack.
[ public ]
Void Clear(Void);

Description

If the type of element is a pointer to a class instance, the instance is not released automatically.

Example

SFXStack<SInt08> stack;
    
...
     
stack.Clear();    // release all the data and memory for management

Reference

SFXStack::Remove


SFXStack::Contains
Check whether the value is contained or not.
[ public, const ]
Bool Contains(
    V value   // value to check
);

Return value

  • If contained : true
  • If not contained : false

Description

If the type of element is a pointer to a class instance, its address is compared with.

Example

SFXStack<SInt08> stack;

// append an element
if (stack.InsertLast(2) == SFERR_NO_ERROR) {
    // append an element
    if (stack.InsertLast(5) == SFERR_NO_ERROR) {
        // check whether the element is contained or not
        TRACE("Contains(2) = %s", (stack.Contains(2)) ? ("true") : ("false"));  // contains(2) = true
        TRACE("Contains(4) = %s", (stack.Contains(4)) ? ("true") : ("false"));  // contains(4) = false
    }
}

Reference

SFXStack::FirstIndexOf


SFXStack::EmptyInstance
Get an empty stack.
[ public, static ]
SFXStack< V > const & EmptyInstance(Void);

Description

Get an instance that represents an empty stack.


SFXStack::Equals
Check whether to equal the specified stack or not.
[ public, const ]
Bool Equals(
    SFXStack< V > const & collection   // stack to compare with
);

Return value

  • If equal : true
  • If not equal : false

Description

Check about two stacks 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.


SFXStack::FirstIndexOf
Get the first index of the element matching with the specified value, searching from the beginning.
[ public, const ]
SInt32 FirstIndexOf(
    V value                         // value to search
    SInt32 index = SINT32_MINIMUM   // beginning index to search from
);

Return value

  • Success : index of the element to match with the value
  • If failed : -1

Description

Search from beginning to end, and get the first index of the element to match with the 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.

Example

SFXStack<SInt08> stack;

// append an element
if (stack.InsertLast(2) == SFERR_NO_ERROR) {
    // append an element
    if (stack.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", 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
    }
}

Reference

SFXStack::Contains | SFXStack::LastIndexOf


SFXStack::Get
Get an element.
[ public, const ]
V Get(
    SInt32 index   // index of the element to get
);

Reference

SFXStack::GetFirst | SFXStack::GetLast | SFXStack::Insert | SFXStack::Remove | SFXStack::Set


SFXStack::GetCluster
Get the cluster size of internal buffer memory.
[ public, const ]
UInt16 GetCluster(Void);

Reference

SFXStack::SetCluster


SFXStack::GetEnumerator
Get an enumerator.
[ public, const ]
Enumerator GetEnumerator(
    SInt32 index   // index to start
);

Reference

SFXStack::GetIterator | SFXStack::Enumerator


SFXStack::GetFirst
Get the first element.
[ public, const ]
V GetFirst(Void);

Reference

SFXStack::Get | SFXStack::GetLast


SFXStack::GetFirstEnumerator
Get the enumerator that points to the first element.
[ public, const ]
Enumerator GetFirstEnumerator(Void);

Example

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 
        }
    }
}

Reference

SFXStack::GetFirstIterator | SFXStack::Enumerator


SFXStack::GetFirstIterator
Get the iterator that points to the first element.
[ public ]
Iterator GetFirstIterator(Void);

Example

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 
        }
    }
}

Reference

SFXStack::GetFirstEnumerator | SFXStack::Iterator


SFXStack::GetIterator
Get an iterator.
[ public ]
Iterator GetIterator(
    SInt32 index   // index to start
);

Reference

SFXStack::GetEnumerator | SFXStack::Iterator


SFXStack::GetLast
Get the last element.
[ public, const ]
V GetLast(Void);

Reference

SFXStack::Get | SFXStack::GetFirst | SFXStack::Peek


SFXStack::GetLastEnumerator
Get the enumerator that points to the last element.
[ public, const ]
Enumerator GetLastEnumerator(Void);

Reference

SFXStack::GetLastIterator | SFXStack::Enumerator


SFXStack::GetLastIterator
Get the iterator that points to the last element.
[ public ]
Iterator GetLastIterator(Void);

Reference

SFXStack::GetLastEnumerator | SFXStack::Iterator


SFXStack::GetSize
Get the size(the number of elements).
[ public, const ]
SInt32 GetSize(Void);

Example

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 elements)
        TRACE("%d", stack.GetSize());  // 2
    }
}

Reference

SFXStack::SetSize


SFXStack::GetThreshold
Get the minimum value of internal buffer size.
[ public, const ]
UInt16 GetThreshold(Void);

Reference

SFXStack::SetThreshold


SFXStack::Insert
Insert an element.
[ 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
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY
  • If failed : SFERR_FAILED

Description

Insert an element before the specified index.

If the specified index is invalid, the element is inserted at the valid position automatically.

Example

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) {
        // insert an element at the first index
        if (stack.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 (stack.Insert(10, 4) == SFERR_NO_ERROR) {
                // enumerate elements by index
                for (i = 0; i < stack.GetSize(); ++i) {
                    TRACE("%d", stack[i]);  // 3 2 5 4
               }
           }
       }
    }

Reference

SFXStack::Get | SFXStack::InsertFirst | SFXStack::InsertLast | SFXStack::Remove | SFXStack::Set


SFXStack::InsertFirst
Insert an element at the beginning.
[ public ]
SFCError InsertFirst(
    SFXStack< V > const & collection   // stack to insert
);
[ public ]
SFCError InsertFirst(
    V value   // value of the element to insert
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY
  • If failed : SFERR_FAILED

Reference

SFXStack::Insert | SFXStack::InsertLast


SFXStack::InsertLast
Insert an element at the end.
[ public ]
SFCError InsertLast(
    SFXStack< V > const & collection   // stack to insert
);
[ public ]
SFCError InsertLast(
    V value   // value of the element to insert
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY
  • If failed : SFERR_FAILED

Reference

SFXStack::Insert | SFXStack::InsertFirst | SFXStack::Push


SFXStack::IsEmpty
Check whether the stack is empty or not.
[ public, const ]
Bool IsEmpty(Void);

Return value

  • If empty : true
  • If not empty : false

SFXStack::LastIndexOf
Get the last index of the element matching with the specified value, searching from the end.
[ public, const ]
SInt32 LastIndexOf(
    V value                         // value to search
    SInt32 index = SINT32_MAXIMUM   // index to search from
);

Return value

  • Success : index of the element to match with the value
  • If failed : -1

Description

Search from end to beginning, and get the last index of the element to match with the 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.

Example

SFXStack<SInt08> stack;

// append an element
if (stack.InsertLast(2) == SFERR_NO_ERROR) {
    // append an element
    if (stack.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", 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
    }
}

Reference

SFXStack::Contains | SFXStack::FirstIndexOf | SFXStack::Search


SFXStack::Peek
Get the top element of stack, but don't remove it.
[ public, const ]
V Peek(Void);

Example

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
        }
    }
}

Reference

SFXStack::Get | SFXStack::GetFirst | SFXStack::GetLast


SFXStack::Pop
Get the top element of stack and remove it.
[ public ]
V Pop(Void);

Example

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
          
          }
    }
}

Reference

SFXStack::Get | SFXStack::GetFirst | SFXStack::GetLast | SFXStack::Remove | SFXStack::RemoveFirst | SFXStack::RemoveLast | SFXStack::Peek SFXStack::Push


SFXStack::Push
Append an element onto the stack.
[ public ]
SFCError Push(
    V value   // element to append(push)
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMOERY
  • If failed : SFERR_FAILED

Description

Inside the Push function, the SFXStack::InsertLast function is called.

Example

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
        }
    }
}

Reference

SFXStack::Insert | SFXStack::InsertLast | SFXStack::Set | SFXStack::Pop | SFXStack::Peek


SFXStack::Remove
Remove the elements at the specified index or range.
[ public ]
Void Remove(
    SInt32 index   // index to remove
);
[ public ]
Void Remove(
    SInt32 begin   // beginning index to remove
    SInt32 end     // end index to remove
);

Example

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) {
        // insert an element at the beginning index
        if (stack.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 (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
               }
           }
       }
    }
}

Reference

SFXStack::Insert | SFXStack::Get | SFXStack::Set


SFXStack::RemoveFirst
Remove the first element.
[ public ]
Void RemoveFirst(Void);

Reference

SFXStack::Remove | SFXStack::RemoveLast


SFXStack::RemoveLast
Remove the last element.
[ public ]
Void RemoveLast(Void);

Reference

SFXStack::Remove | SFXStack::RemoveFirst


SFXStack::Search
Get the index of element to match with the specified value, searching from the top of stack.
[ public, const ]
SInt32 Search(
    V value   // value of the element to search for
);

Return value

  • Success : index of the element from the top of stack to match with the value
  • If failed : -1

Example

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
        }
    }
}

Reference

SFXStack::Contains | SFXStack::FirstIndexOf | SFXStack::LastIndexOf


SFXStack::Set
Set a value to the element. Or set a stack.
[ 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
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory : SFERR_NO_MEMOERY
  • If invalid parameter : SFERR_INVALID_PARAM
  • If failed : SFERR_FAILED

Example

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) {
        // 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
           }
       }
    }
}

Reference

SFXStack::Get | SFXStack::Insert | SFXStack::Remove


SFXStack::SetCluster
Set the cluster size of internal buffer memory.
[ public ]
Void SetCluster(
    UInt16 size   // cluster size to set
);

Reference

SFXStack::GetCluster


SFXStack::SetFirst
Set a value to the first element.
[ public ]
SFCError SetFirst(
    V value   // value of the element to set
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_STATE

Reference

SFXStack::GetFirst


SFXStack::SetLast
Set a value to the last element.
[ public ]
SFCError SetLast(
    V value   // value of the element to set
);

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_INVALID_STATE

Reference

SFXStack::GetLast


SFXStack::SetSize
Set the size of stack. ( Set the number of elements )
[ public ]
SFCError SetSize(
    SInt32 size   // size to set
);

Return value

  • Success : SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

If the specified size is smaller than the size of current stack, elements after the specified size are removed.

Reference

SFXStack::GetSize


SFXStack::SetThreshold
Set the minimum value of internal buffer size.
[ public ]
Void SetThreshold(
    UInt16 size   // minimum value to set
);

Reference

SFXStack::GetThreshold


SFXStack::operator[]
Get the element by index.
[ public ]
V & operator[](
    SInt32 index   // index of element to get
);
[ public, const ]
V const & operator[](
    SInt32 index   // index of element to get
);

Reference

SFXStack::Get | SFXStack::Set


SFXStack::DefaultEnum
Default values of minimun heap size and cluster size used inside the stack.
enum DefaultEnum {
    DEFAULT_THRESHOLD           = 4 * sizeof(VoidPtr),     // default value of minimum heap size
    DEFAULT_CLUSTER             = 8 * sizeof(VoidPtr)      // default value of cluster size
};

Description

SFXStack::DefaultEnum has default values of minimun heap size and cluster size used inside the SFXStack class.

Concretely, they are set as follows.

  • DEFAULT_THRESHOLD ( minimum heap size ) = 4 * sizeof(VoidPtr)
  • DEFAULT_CLUSTER ( cluster size ) = 8 * sizeof(VoidPtr)

Reference

SFXStack::GetCluster | SFXStack::GetThreshold | SFXStack::SetCluster | SFXStack::SetThreshold


SFXStack::Enumerator
Class for managing an enumerator.
[ 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;
};

Description

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.

Example

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 
        }
    }
}

Reference

SFXStack::Iterator


SFXStack::Iterator
Class for managing an iterator.
[ 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;
};

Description

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.

Example

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 
        }
    }
}

Reference

SFXStack::Enumerator