tsc_XCodeList
This class provides a list of X_Codes. Because X_Codes are a simple type (enum), operations perform copies rather than making references.
Storing an X_NULL item in the list is not generally advisable; some API methods that accept tsc_XCodeList objects will use the X_NULL as a list terminator, however the tsc_XCodeList itself does not treat X_NULL as special.
Public methods
tsc_XCodeList ()
Constructs an empty list. Internally, no memory is allocated until an item is added to the list.
tsc_XCodeList (const tsc_XCodeList &fromXCodeList)
Constructs a copy of the supplied list. This is a clone rather than a reference.
tsc_XCodeList (const x_Code fromXNullTerminatedArray[])
Constructs from an X_NULL terminated array.
For example:
X_Code arr[] = {X_Three, X_Two, X_One, PX_LiftOff, X_NULL};
tsc_XCodeList countDown = new tsc_XCodeList (arr);
tsc_XCodeList (const x_Code fromArray[], int itemCount)
Constructs from an array of x-codes of a given size.
X_Code arr[] = {X_Three, X_Two, X_One, PX_LiftOff};
tsc_XCodeList countDown = new tsc_XCodeList (arr, sizeof(arr) / sizeof(arr[0]) );
tsc_XCodeList (x_Code v0, x_Code v1=X_NULL, x_Code v2=X_NULL, x_Code v3=X_NULL, x_Code v4=X_NULL, x_Code v5=X_NULL, x_Code v6=X_NULL, x_Code v7=X_NULL, x_Code v8=X_NULL, x_Code v9=X_NULL)
Constructs a list from between one and ten x-codes supplied individually as parameters. To construct a list of more than ten items, use one of the constructors that accepts an array of x-codes, and define the array separately. Example:
For example:
tsc_XCodeList list = new tsc_XCodeList (X_One, X_Two, X_Three);
int Count () const
The number of x-codes in the list. Internally, the list may be terminated by an X_NULL item, but this is never included in the Count.
const x_Code* AsArray () const
Returns the list as an array of x_Codes. The returned address points to the internal list, which should not be changed. The array will be terminated by an X_NULL item, which is not included in the list's count.
void Append (x_Code code)
Appends an item to the end of the list. Appending an X_NULL is not advisable; some methods that accept tsc_XCodeList objects will use the X_NULL as a list terminator.
bool Contains (x_Code xcodeToFind)
Returns true if the item exists in the list.
int IndexOf (x_Code xcodeToFind)
Returns the index of the item, or -1 if no matching x-code is found.
void Filter (tsc_XCodeList &filterSet)
Removes from the list any item that is not in filterSet.
void Clear ()
Empties the list and frees the internal memory.
tsc_XCodeList & operator+= (x_Code code)
Adds an x-code to the end of the list.
tsc_XCodeList & operator+= (const tsc_XCodeList &from)
Adds the contents of another list.
x_Code & operator[] (int index)
Returns the item at index, which allows item to be changed.
For example:
myList[6] = X_Distance;
x_Code operator[] (int index) const
Returns a copy of the item at index.
tsc_XCodeList & operator= (const tsc_XCodeList &from)
Assignment of the list. Unlike many Scapi objects, this is a copy operation, not a reference.