![]() ![]() ![]()
|
SophiaFramework UNIVERSE 5.1 |


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
| 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 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 the iterator that points to the element at the specified index.
|
| 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 the elements).
|
| SFCError |
Insert(
SInt32 index
, SFXList< V > const & collection
) Insert elements before the specified index.
|
| SFCError |
Insert(
SInt32 index
, V value
) Insert elements before the specified index.
|
| SFCError |
InsertFirst(
SFXList< V > const & collection
) Insert elements at the head.
|
| SFCError |
InsertFirst(
V value
) Insert elements at the head.
|
| SFCError |
InsertLast(
SFXList< V > const & collection
) Insert elements at the tail.
|
| SFCError |
InsertLast(
V value
) Insert elements 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 specified element.
|
| SFCError |
MoveFirst(
SInt32 source
) Move the specified element at the beginning.
|
| SFCError |
MoveLast(
SInt32 source
) Move the specified element at the end.
|
| Void |
Remove(
SInt32 index
) Remove elements at the specified index or range.
|
| Void |
Remove(
SInt32 begin
, SInt32 end
) Remove elements at the specified index or range.
|
| Void |
RemoveFirst( Void ) Remove the first element.
|
| Void |
RemoveLast( Void ) Remove the last element.
|
| 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 a value to the first element.
|
| SFCError |
SetLast(
V value
) Set a value to the last element.
|
| SFCError |
Swap(
SInt32 destination
, SInt32 source
) Swap specified two elements.
|
| SFCError |
SwapFirst(
SInt32 source
) Swap the specified element for the first element.
|
| SFCError |
SwapLast(
SInt32 source
) Swap the specified element with the last element.
|
| Types |
|---|
|
Enumerator Class for managing an enumerator.
|
|
Iterator
Class for managing an iterator.
|
[ public, explicit ] SFXList(Void);
[ public ] SFCError Append( SFXList< V > const & collection // list to append );
[ public ] SFCError Append( V value // element to append );
Append an element at the end of list. This function is deprecated, use the SFXList::InsertLast function.
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 } } }
SFXList::Insert | SFXList::InsertLast | SFXList::Get | SFXList::Remove | SFXList::Set
[ public ] Void Clear(Void);
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 |
|---|---|
|
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 |
|---|---|
| This function will be called automatically when this list goes out of scope. | |
SFXList<SInt32> list;
...
list.Clear(); // clear the list
[ public, const ] Bool Contains( V value // value to check );
This function checks whether or not this list 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. | |
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 } }
[ public, static ] SFXList< V > const & EmptyInstance(Void);
Get an instance that represents an empty list.
[ public, const ] Bool Equals( SFXList< V > const & collection // list to compare with );
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 |
|---|---|
| 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 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 |
|---|---|
| If the type of the element is a pointer, its address will be compared. | |
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 } }
[ public, const ]
V Get(
SInt32 index // index of the element to get
);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. | |
SFXList::GetFirst | SFXList::GetLast | SFXList::Insert | SFXList::Remove | SFXList::Set
[ 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 list 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 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. | |
SFXList::GetFirstEnumerator | SFXList::GetLastEnumerator | SFXList::GetIterator | SFXList::Enumerator
[ public, const ] V GetFirst(Void);
[ public, const ] Enumerator GetFirstEnumerator(Void);
Enumerator that points to the first element
This function gets the enumerator of this list that points to the first element.
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 } } }
[ public ] Iterator GetFirstIterator(Void);
Iterator that points to the first element
This function gets the iterator of this list that points to the first element.
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 } } }
SFXList::GetIterator | SFXList::GetFirstEnumerator | SFXList::Iterator
[ 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 list 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 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. | |
SFXList::GetFirstIterator | SFXList::GetLastIterator | SFXList::GetEnumerator | SFXList::Iterator
[ public, const ] V GetLast(Void);
[ public, const ] Enumerator GetLastEnumerator(Void);
Enumerator that points to the last element
This function gets the enumerator of this list that points to the last element.
[ public ] Iterator GetLastIterator(Void);
Iterator that points to the last element
This function gets the iterator of this list that points to the last element.
SFXList::GetIterator | SFXList::GetLastEnumerator | SFXList::Iterator
[ public, const ] SInt32 GetSize(Void);
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 } }
[ public ] SFCError Insert( SInt32 index // index to insert SFXList< V > const & collection // value of the element to insert );
[ public ] SFCError Insert( SInt32 index // index to insert V value // value of the element to insert );
This function inserts elements 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.
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 } } } } }
SFXList::InsertFirst | SFXList::InsertLast | SFXList::Remove | SFXList::Get | SFXList::Set
[ public ] SFCError InsertFirst( SFXList< V > const & collection // list to insert );
[ public ] SFCError InsertFirst( V value // value of the element to insert );
This function inserts elements at the head.
SFXList::Insert | SFXList::InsertLast | SFXList::RemoveFirst
[ public ] SFCError InsertLast( SFXList< V > const & collection // list to insert );
[ public ] SFCError InsertLast( V value // value of the element to insert );
This function inserts elements at the tail.
SFXList::Insert | SFXList::InsertFirst | SFXList::RemoveLast
[ public, const ] Bool IsEmpty(Void);
This function checks whether or not this list 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 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 |
|---|---|
| If the type of the element is a pointer, its address will be compared. | |
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 } }
[ public ] Void Remove( SInt32 index // index to remove );
[ public ] Void Remove( SInt32 begin // beginning index to remove(this index is included) SInt32 end // ending index to remove(this index is not included) );
This function removes an element at the specified index or 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.
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 } } } } }
SFXList::RemoveFirst | SFXList::RemoveLast | SFXList::Insert | SFXList::Get | SFXList::Set
[ public ] Void RemoveFirst(Void);
This function removes the first element.
SFXList::Remove | SFXList::RemoveLast | SFXList::InsertFirst
[ public ] Void RemoveLast(Void);
This function removes the last element.
SFXList::Remove | SFXList::RemoveFirst | SFXList::InsertLast
[ public ] SFCError Set( SFXList< V > const & collection // list to set );
[ public ] SFCError Set( SInt32 index // index to set V value // value to set );
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.
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 } } } }
[ public ] SFCError SetFirst( V value // value to set );
[ public ] SFCError SetLast( V value // value to set );
[ 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. |
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 } } }
[ 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;
};
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. |
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 } } }
|
Copyright(c) 2002 - 2010 Sophia Cradle Incorporated All Rights Reserved. |
![]() ![]() ![]()
|