PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFXList
Class which represents a bidirectional linked list.
#include <SFXList.h.hpp>
class SFXList;
SFMTYPEDEFCLASS(SFXList)

Inheritance diagram

 Inheritance diagram of SFXListClass

Collaboration diagram

 Collaboration diagram of SFXListClass

Description

SFXList is data structure for operating a multiple of the elements as a two-way linked list. Memory allocation and release will be performed for each element.

[Note] SFXList and SFXArray

In the SFXList class, inserting or deleting an element is only to maintain the pointers of the element in question and the neighboring elements. On the other hand, in the SFXArray class, it is necessay to to move elements after the element in question in the internal buffer memory. Therefore, inserting or deleting an element is faster than in the SFXArray class.

In the SFXList class, accessing an element needs to be traversed via a two-way linked list. On the other hand, in the SFXArray class, an element can be directly accessed using the index. Therefore, accessing an element is slower than in the SFXArray class.

Each element size of SFXList 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 SFXList instance ( bidirectional linked list ), a pointer should be used.

// data more than 4 byte or class instance cannot be an element of the SFXList instance ( bidirectional linked list ) 

// SFXList<SInt64> ar64;           NG
// SFXList<SFXAnsiString> arstr;   NG


// but a pointer to the data more than 4 byte or class instance can be an element of the SFXList instance ( bidirectional linked list )

SFXList<SInt64Ptr> ar64;        // OK
SFXList<SFXAnsiStringPtr> arstr;// OK

Reference

SFXArray | SFXStack | List

Member

Constructor/Destructor
SFXList( Void )
Constructor of the SFXList class.
Public Functions
SFCError Append( SFXList< V > const & collection )
[DEPRECATED] Append an element.
SFCError Append( V value )
[DEPRECATED] Append an element.
Void Clear( Void )
Clear this list.
Bool Contains( V value )
Check whether or not this list contains the specified value.
static
SFXList< V > const &
EmptyInstance( Void )
Get an empty list.
Bool Equals( SFXList< V > const & collection )
Check whether or not this list equals the specified list.
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.
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).
SFCError Insert( SInt32 index , SFXList< V > const & collection )
Insert the specified element or list before the specified index.
SFCError Insert( SInt32 index , V value )
Insert the specified element or list before the specified index.
SFCError InsertFirst( SFXList< V > const & collection )
Insert the specified element or list at the head.
SFCError InsertFirst( V value )
Insert the specified element or list at the head.
SFCError InsertLast( SFXList< V > const & collection )
Insert the specified element or list at the tail.
SFCError InsertLast( V value )
Insert the specified element or list at the tail.
Bool IsEmpty( Void )
Check whether or not this list 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.
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.
SFCError Set( SFXList< V > const & collection )
Set the element at the specified index of this list to the specified value. Or set this list to the specified list.
SFCError Set( SInt32 index , V value )
Set the element at the specified index of this list to the specified value. Or set this list to the specified list.
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 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.
Types
Enumerator
Class for managing the enumerator of this list.
Iterator
Class for managing the iterator of this list.

SFXList::SFXList
Constructor of the SFXList class.
[ public, explicit ]
SFXList(Void);

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

Return value

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

Description

Append an element at the end of list. This function is deprecated, use the SFXList::InsertLast function.

Example

SFXList<SInt32> list;
SInt16 i;

// append an element
if (list.Append(2) == SFERR_NO_ERROR) {
    // append an element
    if (list.Append(5) == SFERR_NO_ERROR) {
        // enumerate by index
        for (i = 0; i < list.GetSize(); ++i) {
            TRACE("%d", list.Get(i));  // 2 5 
        }
    }
}

Reference

SFXList::Insert | SFXList::InsertLast | SFXList::Get | SFXList::Remove | SFXList::Set


SFXList::Clear
Clear this list.
[ public ]
Void Clear(Void);

Description

This function clears this list. All the memory areas allocated to the elements of this list will be released.

After this function is executed, the size of this list will become 0.

[Caution] 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 list, it is necessary to release that area explicitly using the delete statement. Otherwise, memory leakage will occur.

[Note] Note
This function will be called automatically when this list goes out of scope.

Example

SFXList<SInt32> list;
    
...
     
list.Clear();    // clear the list

Reference

SFXList::Remove


SFXList::Contains
Check whether or not this list contains the specified value.
[ public, const ]
Bool Contains(
    V value   // value to check
);

Return value

  • If the specified value is contained: true
  • Otherwise: false

Description

This function checks whether or not this list contains the specified value.

[Note] 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.

Example

SFXList<SInt32> list;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {

    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {

        // check whether or not the stack contains the elements below
        TRACE("Contains(2) = %s", (list.Contains(2)) ? ("true") : ("false"));  // contains(2) = true
        TRACE("Contains(4) = %s", (list.Contains(4)) ? ("true") : ("false"));  // contains(4) = false
    }
}

Reference

SFXList::FirstIndexOf | SFXList::LastIndexOf


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

Description

Get an instance that represents an empty list.


SFXList::Equals
Check whether or not this list equals the specified list.
[ public, const ]
Bool Equals(
    SFXList< V > const & collection   // list to compare with
);

Return value

  • If this list equals the specified list: true
  • Otherwise: false

Description

This function checks whether or not this list equals the specified list (whether or not the same elements are saved in the same order).

[Note] Note
If the type of the element is a pointer, its address will be compared.

SFXList::FirstIndexOf
Get the first index of the element that equals the specified value, searching from the head.
[ public, const ]
SInt32 FirstIndexOf(
    V value                         // value to search
    SInt32 index = SINT32_MINIMUM   // index to search from
);

Return value

  • If succeeds: index of the element that equals the specified value
  • If failed: -1

Description

This function gets the first index of the element of this list 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] Note
If the type of the element is a pointer, its address will be compared.

Example

SFXList<SInt32> list;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {

    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {

        // get the first index of the element that equals the specified value, searching from the beginning
        TRACE("FirstIndexOf(1) = %d", list.FirstIndexOf(1));  // firstIndexOf(1) = -1
        TRACE("FirstIndexOf(2) = %d", list.FirstIndexOf(2));  // firstIndexOf(2) = 0
        TRACE("FirstIndexOf(5) = %d", list.FirstIndexOf(5));  // firstIndexOf(5) = 1
    }
}

Reference

SFXList::Contains | SFXList::LastIndexOf


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

Return value

Element at the index specified in the argument. 0 or null will be returned if no element exists at the specified index.

Return value

This function gets the element at the index specified in the argument.

[Caution] Caution
In case no element exists at the specified index, no error will occur but this function will return 0 or null.

Reference

SFXList::GetFirst | SFXList::GetLast | SFXList::Insert | SFXList::Remove | SFXList::Set


SFXList::GetEnumerator
Get the enumerator that points to the element at the specified index.
[ public, const ]
Enumerator GetEnumerator(
    SInt32 index   // index to start
);

Return value

Enumerator that points to the element at the specified index

Description

This function gets the enumerator of this list that points to the element at the specified index.

[Note] Note

If the specified index is less than or equals 0, this function is same as the SFXList::GetFirstEnumerator function.

If the specified index is more than or equals the size of this list, this function is same as the SFXList::GetLastEnumerator function.

Reference

SFXList::GetFirstEnumerator | SFXList::GetLastEnumerator | SFXList::GetIterator | SFXList::Enumerator


SFXList::GetFirst
Get the element at the head.
[ public, const ]
V GetFirst(Void);

Return value

Element at the head. 0 or null will be returned if no element exists in this list.

Description

This function gets the element at the head.

[Caution] Caution
In case no element exists in this list, no error will occur but this function will return 0 or null.

Reference

SFXList::Get | SFXList::GetLast | SFXList::InsertFirst | SFXList::RemoveFirst


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

Return value

Enumerator that points to the first element

Description

This function gets the enumerator of this list that points to the first element.

Example

SFXList<SInt32> list;
SFXList<SInt32>::Enumerator en;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {
    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {
        
        // get the enumerator that points to the first element
        en = list.GetFirstEnumerator();
        
        // check whether the next element exists or not
        while(en.HasNext()) {
            TRACE("%d", en.GetNext());  // 2 5 
        }
    }
}

Reference

SFXList::GetEnumerator | SFXList::GetFirstIterator | SFXList::Enumerator


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

Return value

Iterator that points to the first element

Description

This function gets the iterator of this list that points to the first element.

Example

SFXList<SInt32> list;
SFXList<SInt32>::Iterator it;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {
    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {
        
        // get the iterator that points to the first element
        it = list.GetFirstIterator();
        
        // check whether the next element exists or not
        while(it.HasNext()) {
            TRACE("%d", it.GetNext());  // 2 5 
        }
    }
}

Reference

SFXList::GetIterator | SFXList::GetFirstEnumerator | SFXList::Iterator


SFXList::GetIterator
Get the iterator that points to the element at the specified index.
[ public ]
Iterator GetIterator(
    SInt32 index   // index to start
);

Return value

Iterator that points to the element at the specified index

Description

This function gets the iterator of this list that points to the element at the specified index.

[Note] Note

If the specified index is less than or equals 0, this function is same as the SFXList::GetFirstIterator function.

If the specified index is more than or equals the size of this list, this function is same as the SFXList::GetLastIterator function.

Reference

SFXList::GetFirstIterator | SFXList::GetLastIterator | SFXList::GetEnumerator | SFXList::Iterator


SFXList::GetLast
Get the element at the tail.
[ public, const ]
V GetLast(Void);

Return value

Element at the tail. 0 or null will be returned if no element exists in this list.

Description

This function gets the element at the tail.

[Caution] Caution
In case no element exists in this list, no error will occur but this function will return 0 or null.

Reference

SFXList::Get | SFXList::GetFirst | SFXList::InsertLast | SFXList::RemoveLast


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

Return value

Enumerator that points to the last element

Description

This function gets the enumerator of this list that points to the last element.

Reference

SFXList::GetEnumerator | SFXList::GetLastIterator | SFXList::Enumerator


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

Return value

Iterator that points to the last element

Description

This function gets the iterator of this list that points to the last element.

Reference

SFXList::GetIterator | SFXList::GetLastEnumerator | SFXList::Iterator


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

Example

SFXList<SInt32> list;
SInt16 i;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {
    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {
        // display the size(the number of the elements)
        TRACE("%d", list.GetSize());  // 2
    }
}

SFXList::Insert
Insert the specified element or list before the specified index.
[ public ]
SFCError Insert(
    SInt32 index                      // index to insert
    SFXList< V > const & collection   // list to insert
);
[ public ]
SFCError Insert(
    SInt32 index   // index to insert
    V value        // value of the element to insert
);

Return value

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

Description

This function inserts the specified element or list 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.

Example

SFXList<SInt16> list;
SInt16 i;

// insert an element at the tail
if (list.InsertLast(2) == SFERR_NO_ERROR) {

    // insert an element at the tail
    if (list.InsertLast(5) == SFERR_NO_ERROR) {

        // insert an element at the head
        if (list.Insert(0, 3) == SFERR_NO_ERROR) {

            // insert an element at 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 (list.Insert(10, 4) == SFERR_NO_ERROR) {

                // remove elements from the 1st index to the 2nd index
                list.Remove(1, 3);

                // enumerate elements by index
                for (i = 0; i < list.GetSize(); ++i) {

                    TRACE("%d", list.Get(i));  // 3 4
               }
           }
       }
    }
}

Reference

SFXList::InsertFirst | SFXList::InsertLast | SFXList::Set | SFXList::Get | SFXList::Remove


SFXList::InsertFirst
Insert the specified element or list at the head.
[ public ]
SFCError InsertFirst(
    SFXList< V > const & collection   // list to insert
);
[ public ]
SFCError InsertFirst(
    V value   // value of the element to insert
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function inserts the specified element or list at the head.

Reference

SFXList::Insert | SFXList::InsertLast | SFXList::RemoveFirst | SFXList::GetFirst


SFXList::InsertLast
Insert the specified element or list at the tail.
[ public ]
SFCError InsertLast(
    SFXList< V > const & collection   // list to insert
);
[ public ]
SFCError InsertLast(
    V value   // value of the element to insert
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function inserts the specified element or list at the tail.

Reference

SFXList::Insert | SFXList::InsertFirst | SFXList::GetLast | SFXList::RemoveLast


SFXList::IsEmpty
Check whether or not this list is empty.
[ public, const ]
Bool IsEmpty(Void);

Return value

  • If empty: true
  • Otherwise: false

Description

This function checks whether or not this list is empty.


SFXList::LastIndexOf
Get the last index of the element that equals the specified value, searching from the tail.
[ public, const ]
SInt32 LastIndexOf(
    V value                         // value to search
    SInt32 index = SINT32_MAXIMUM   // index to search from
);

Return value

  • If succeeds: index of the element that equals the specified value
  • If failed: -1

Description

This function gets the last index of the element of this list 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] Note
If the type of the element is a pointer, its address will be compared.

Example

SFXList<SInt32> list;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {

    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {

        // get the last index of the element that equals the specified value, searching from the end
        TRACE("LastIndexOf(1) = %d", list.LastIndexOf(1));  // lastIndexOf(1) = -1
        TRACE("LastIndexOf(2) = %d", list.LastIndexOf(2));  // lastIndexOf(2) = 0
        TRACE("LastIndexOf(5) = %d", list.LastIndexOf(5));  // lastIndexOf(5) = 1
    }
}

Reference

SFXList::Contains | SFXList::FirstIndexOf


SFXList::Move
Move the element at the specified index to the specified index.
[ public ]
SFCError Move(
    SInt32 destination   // destination index of the element to move
    SInt32 source        // source index of the element to move
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If no element exists at the specified index: SFERR_INVALID_PARAM

Description

This function moves the element at the specified index to the specified index.

Reference

SFXList::MoveFirst | SFXList::MoveLast


SFXList::MoveFirst
Move the element at the specified index to the head.
[ public ]
SFCError MoveFirst(
    SInt32 source   // source index
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If this list is empty: SFERR_INVALID_STATE
  • If no element exists at the specified index: SFERR_INVALID_PARAM

Description

This function moves the element at the specified index to the head.

Reference

SFXList::Move | SFXList::MoveLast


SFXList::MoveLast
Move the element at the specified index to the tail.
[ public ]
SFCError MoveLast(
    SInt32 source   // source index
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If this list is empty: SFERR_INVALID_STATE
  • If no element exists at the specified index: SFERR_INVALID_PARAM

Description

This function moves the element at the specified index to the tail.

Reference

SFXList::Move | SFXList::MoveFirst


SFXList::Remove
Remove the elements at the specified index or range.
[ 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)
);

Description

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] Caution
If no element exists at the specified index or range, no error will occur and nothing will happen.

Example

SFXList<SInt16> list;
SInt16 i;

// insert an element at the tail
if (list.InsertLast(2) == SFERR_NO_ERROR) {

    // insert an element at the tail
    if (list.InsertLast(5) == SFERR_NO_ERROR) {

        // insert an element at the head
        if (list.Insert(0, 3) == SFERR_NO_ERROR) {

            // insert an element at 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 (list.Insert(10, 4) == SFERR_NO_ERROR) {

                // remove elements from 2nd to 3rd
                list.Remove(1, 3);

                // enumerate elements by index
                for (i = 0; i < list.GetSize(); ++i) {

                    TRACE("%d", list.Get(i));  // 3 4
               }
           }
       }
    }
}

Reference

SFXList::RemoveFirst | SFXList::RemoveLast | SFXList::Insert | SFXList::Get | SFXList::Set


SFXList::RemoveFirst
Remove the element at the head.
[ public ]
Void RemoveFirst(Void);

Description

This function removes the element at the head.

[Caution] Caution
If no element exists in this list, no error will occur and nothing will happen.

Reference

SFXList::Remove | SFXList::RemoveLast | SFXList::GetFirst | SFXList::InsertFirst


SFXList::RemoveLast
Remove the element at the tail.
[ public ]
Void RemoveLast(Void);

Description

This function removes the element at the tail.

[Caution] Caution
If no element exists in this list, no error will occur and nothing will happen.

Reference

SFXList::Remove | SFXList::RemoveFirst | SFXList::GetLast | SFXList::InsertLast


SFXList::Set
Set the element at the specified index of this list to the specified value. Or set this list to the specified list.
[ public ]
SFCError Set(
    SFXList< V > const & collection   // list to set
);
[ public ]
SFCError Set(
    SInt32 index   // index to set
    V value        // value to set
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY
  • If no element exists at the specified index: SFERR_INVALID_PARAM

Description

This function sets the element at the specified index of this list to the specified value, or sets this list to the specified list.

* In case an error occurs during processing, this list will be restored.

Example

SFXList<SInt32> list;
SInt16 i;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {

    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {

        // set a value to the element
        if (list.Set(1, 10) == SFERR_NO_ERROR) {

            // enumerate elements by index
            for (i = 0; i < list.GetSize(); ++i) {

                TRACE("%d", list.Get(i));  // 2 10
           }
       }
    }
}

Reference

SFXList::Get | SFXList::Insert | SFXList::Remove


SFXList::SetFirst
Set the element at the head to the specified value.
[ public ]
SFCError SetFirst(
    V value   // value to set
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If this list is empty: SFERR_INVALID_STATE

Description

This function sets the element at the head to the specified value.

Reference

SFXList::GetFirst | SFXList::Set | SFXList::SetLast


SFXList::SetLast
Set the element at the tail to the specified value.
[ public ]
SFCError SetLast(
    V value   // value to set
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If this list is empty: SFERR_INVALID_STATE

Description

This function sets the element at the tail to the specified value.

Reference

SFXList::GetLast | SFXList::Set | SFXList::SetFirst


SFXList::Swap
Swap two elements at the specified indexes.
[ public ]
SFCError Swap(
    SInt32 destination   // destination index
    SInt32 source        // source index
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If no element exists at the specified index: SFERR_INVALID_PARAM

Description

This function swaps two elements at the specified indexes.

Reference

SFXList::SwapFirst | SFXList::SwapLast


SFXList::SwapFirst
Swap the element at the specified index for the element at the head.
[ public ]
SFCError SwapFirst(
    SInt32 source   // source index
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If this list is empty: SFERR_INVALID_STATE
  • If no element exists at the specified index: SFERR_INVALID_PARAM

Description

This function swaps the element at the specified index for the element at the head.

Reference

SFXList::Swap | SFXList::SwapLast


SFXList::SwapLast
Swap the element at the specified index for the element at the tail.
[ public ]
SFCError SwapLast(
    SInt32 source   // source index
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If this list is empty: SFERR_INVALID_STATE
  • If no element exists at the specified index: SFERR_INVALID_PARAM

Description

This function swaps the element at the specified index for the element at the tail.

Reference

SFXList::Swap | SFXList::SwapFirst


SFXList::Enumerator
Class for managing the enumerator of this list.
[ 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;
};

Description

This class is for managing the enumerator of this list.

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.

Example

SFXList<SInt32> list;
SFXList<SInt32>::Enumerator en;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {

    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {
        
        // get the enumerator that points to the first element
        en = list.GetFirstEnumerator();
        
        // check whether the next element exists or not
        while(en.HasNext()) {

            TRACE("%d", en.GetNext());  // 2 5 
        }
    }
}

Reference

SFXList::Iterator


SFXList::Iterator
Class for managing the iterator of this list.
[ 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

This class is for managing the iterator of this list.

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.

Example

SFXList<SInt32> list;
SFXList<SInt32>::Iterator it;

// append an element
if (list.InsertLast(2) == SFERR_NO_ERROR) {
    // append an element
    if (list.InsertLast(5) == SFERR_NO_ERROR) {
        
        // get the iterator that points to the first element
        it = list.GetFirstIterator();
        
        // check whether the next element exists or not
        while(it.HasNext()) {
            TRACE("%d", it.GetNext());  // 2 5 
        }
    }
}

Reference

SFXList::Enumerator