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


Each element of the SFXList instance ( bidirectional linked list ) 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 SFXList instance ( bidirectional linked list ), a pointer should be used.
// data more than 4 bytes 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 bytes 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 SFXList class.
|
| Public Functions | |
|---|---|
| SFCError |
Append(
SFXList< V > const & collection
) Append( V value ) [DEPRECATED] Append an element.
|
| Void |
Clear( Void ) Clear the list.
|
| Bool |
Contains(
V value
) Check whether the value is contained or not.
|
| static SFXList< V > const & |
EmptyInstance( Void ) Get an empty list.
|
| Bool |
Equals(
SFXList< V > const & collection
) Check whether to equal the specified list 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.
|
| 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).
|
| SFCError |
Insert(
SInt32 index
, SFXList< V > const & collection
) Insert( SInt32 index , V value ) Insert an element.
|
| SFCError |
InsertFirst(
SFXList< V > const & collection
) InsertFirst( V value ) Insert an element at the beginning.
|
| SFCError |
InsertLast(
SFXList< V > const & collection
) InsertLast( V value ) Insert an element at the end.
|
| Bool |
IsEmpty( Void ) Check whether the list 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.
|
| Void |
Remove(
SInt32 index
) Remove( SInt32 begin , SInt32 end ) Remove the elements at the specified index or range.
|
| Void |
RemoveFirst( Void ) Remove the first element.
|
| Void |
RemoveLast( Void ) Remove the last element.
|
| SFCError |
Set(
SFXList< V > const & collection
) Set( SInt32 index , V value ) Set a value to the element. Or set a list.
|
| SFCError |
SetFirst(
V value
) Set a value to the first element.
|
| SFCError |
SetLast(
V value
) Set a value to 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 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);
If the type of element is a pointer to a class instance, the instance is not released automatically.
SFXList<SInt32> list;
...
list.Clear(); // release all the data and memory for management
[ public, const ] Bool Contains( V value // value to check );
If the type of element is a pointer to a class instance, its address is compared with.
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 the element is contained or not 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 );
Check about two lists whether the same element is saved in the same order or not.
If the type of element is a pointer to a class instance, its address is compared.
[ public, const ] SInt32 FirstIndexOf( V value // value to search SInt32 index = SINT32_MINIMUM // beginning index to search from );
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.
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 matching with 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
);SFXList::GetFirst | SFXList::GetLast | SFXList::Insert | SFXList::Remove | SFXList::Set
[ public, const ]
Enumerator GetEnumerator(
SInt32 index // index to start
);[ public, const ] V GetFirst(Void);
[ public, const ] Enumerator GetFirstEnumerator(Void);
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);
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 } } }
[ public ]
Iterator GetIterator(
SInt32 index // index to start
);[ public, const ] V GetLast(Void);
[ public, const ] Enumerator GetLastEnumerator(Void);
[ public ] Iterator GetLastIterator(Void);
[ public, const ] SInt32 GetSize(Void);
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 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 );
Insert an element before the specified index.
If the specified index is invalid, the element is inserted at the valid position automatically.
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) { // insert an element at the first index if (list.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 (list.Insert(10, 4) == SFERR_NO_ERROR) { // enumerate elements by index for (i = 0; i < list.GetSize(); ++i) { TRACE("%d", list.Get(i)); // 3 2 5 4 } } } } }
SFXList::Get | SFXList::InsertFirst | SFXList::InsertLast | SFXList::Remove | SFXList::Set
[ public ] SFCError InsertFirst( SFXList< V > const & collection // list to insert );
[ public ] SFCError InsertFirst( V value // value of the element to insert );
[ public ] SFCError InsertLast( SFXList< V > const & collection // list to insert );
[ public ] SFCError InsertLast( V value // value of the element to insert );
[ public, const ] Bool IsEmpty(Void);
[ public, const ] SInt32 LastIndexOf( V value // value to search SInt32 index = SINT32_MAXIMUM // index to search from );
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.
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 matching with 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 SInt32 end // end index to remove );
[ public ] Void RemoveFirst(Void);
[ public ] Void RemoveLast(Void);
[ public ] SFCError Set( SFXList< V > const & collection // list to set );
[ public ] SFCError Set( SInt32 index // index to set V value // value to set );
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 - 2009 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|