Legal Notice, Privacy Policy

Impressum, Datenschutzerklärung

Cerberus X Documentation

Class StringStack

A StringStack is a convenience class for dealing with stacks of strings. More...

Declarations

Extends
Stack : <String> Stacks provide 2 basic operations - push and pop.
Constructors
New () Creates a new empty StringStack.
Methods
Compare : Int ( lhs:String, rhs:String ) Implements the Stack.Compare method, which allows StringStacks to be sorted using the Sort method.
Join : String ( separator:String="" ) Concatenates the elements of the stack and joins them together with separator.
Inherited Properties
IsEmpty : Bool () Return True if the stack is empty, ie: it contains no items, else False.
Length : Int () Returns the number of items in the stack.
Length : Void ( length:Int ) Sets the number of items in the stack.
Inherited Methods
Backwards : Object () Returns an object that may be used to iterate backwards through the stack with a For EachIn loop.
Clear : Void () Removes all items from the stack.
Contains : Bool ( value:T ) Returns true if value is contained in the stack.
Data : T[] () Provides access to the underlying array used to store stack data.
Equals : Bool ( lhs:T, rhs:T ) This method is used by the Contains and RemoveEach methods to determine element equality.
Find : Int ( value:T, start:Int=0 ) Finds the index of the first element in the stack equal to value.
FindLast : Int ( value:T ) Finds the index of the last element in the stack equal to value.
FindLast : Int ( value:T, start:Int ) Finds the index of the last element in the stack equal to value.
Get : T ( index:Int ) Returns the element at the specified index.
Insert : Void ( index:Int, value:T ) Inserts value into the stack, shifting existing elements up if necessary.
ObjectEnumerator : Object () Returns an enumerator object suitable for use with For EachIn loops.
Pop : T () Removes the item at the top of the stack and returns it.
Push : Void ( value:T ) Pushes a value on the top of the stack.
Push : Void ( values:T[] ) Pushes an array of values on the top of the stack starting with element 0.
Remove : Void ( index:Int ) Removes the value at the specified index from the stack, shifting existing elements down if necessary.
RemoveEach : Void ( value:T ) Finds and removes all elements in the stack equal to value, shifting existing elements down if necessary.
RemoveFirst : Void ( value:T ) Finds and removes the first element in the stack equal to value.
RemoveLast : Void ( value:T ) Finds and removes the last element in the stack equal to value.
Set : Void ( index:Int, value:T ) Overwrites the existing value at index with value.
Sort : Int ( ascending:Int=True ) Sorts the stack into ascending or descending order.
ToArray : T[] () Converts the stack to an array of values.
Top : T () Returns the item at the top of the stack.

Detailed Discussion

A StringStack is a convenience class for dealing with stacks of strings.

A StringStack may also be used to efficiently concatenate a large number of strings. Simply use Push to add each string to the stack, and Join to concatenate the strings together.


Constructors Documentation

Method New ()

Creates a new empty StringStack.


Methods Documentation

Method Join : String ( separator:String="" )

Concatenates the elements of the stack and joins them together with separator.

Parameters

separator - string to use to separate elements.