Packagede.polygonal.ds
Classpublic class ArrayedStack
InheritanceArrayedStack Inheritance Object
Implements Collection

An arrayed stack. This is called a LIFO structure (Last In, First Out).

See also

LinkedStack


Public Properties
 PropertyDefined By
  maxSize : int
[read-only] The stack's maximum capacity.
ArrayedStack
  size : int
[read-only] The total number of items.
ArrayedStack
Public Methods
 MethodDefined By
  
ArrayedStack(size:int)
Initializes a stack to match the given size.
ArrayedStack
  
clear():void
Clears all items.
ArrayedStack
  
contains(obj:*):Boolean
Determines if the collection contains a given item.
ArrayedStack
  
dump():String
Prints out all elements (for debug/demo purposes).
ArrayedStack
  
getAt(i:int):*
Reads an item at a given index.
ArrayedStack
  
Initializes an iterator object pointing to the first item in the collection.
ArrayedStack
  
isEmpty():Boolean
Checks if the collection is empty.
ArrayedStack
  
peek():*
Indicates the top item.
ArrayedStack
  
pop():*
Pops data off the stack.
ArrayedStack
  
push(obj:*):Boolean
Pushes data onto the stack.
ArrayedStack
  
setAt(i:int, obj:*):void
Writes an item at a given index.
ArrayedStack
  
toArray():Array
Converts the collection into an array.
ArrayedStack
  
toString():String
Prints out a string representing the current object.
ArrayedStack
Property Detail
maxSizeproperty
maxSize:int  [read-only]

The stack's maximum capacity.


Implementation
    public function get maxSize():int
sizeproperty 
size:int  [read-only]

The total number of items.


Implementation
    public function get size():int
Constructor Detail
ArrayedStack()Constructor
public function ArrayedStack(size:int)

Initializes a stack to match the given size.

Parameters
size:int — The maximum allowed size.
Method Detail
clear()method
public function clear():void

Clears all items.

contains()method 
public function contains(obj:*):Boolean

Determines if the collection contains a given item.

Parameters

obj:* — The item to search for.

Returns
Boolean — True if the item exists, otherwise false.
dump()method 
public function dump():String

Prints out all elements (for debug/demo purposes).

Returns
String — A human-readable representation of the structure.
getAt()method 
public function getAt(i:int):*

Reads an item at a given index.

Parameters

i:int — The index.

Returns
* — The item at the given index.
getIterator()method 
public function getIterator():Iterator

Initializes an iterator object pointing to the first item in the collection.

Returns
Iterator — An iterator object.
isEmpty()method 
public function isEmpty():Boolean

Checks if the collection is empty.

Returns
Boolean — True if empty, otherwise false.
peek()method 
public function peek():*

Indicates the top item.

Returns
* — The top item.
pop()method 
public function pop():*

Pops data off the stack.

Returns
* — A reference to the top item or null if the stack is empty.
push()method 
public function push(obj:*):Boolean

Pushes data onto the stack.

Parameters

obj:* — The data.

Returns
Boolean
setAt()method 
public function setAt(i:int, obj:*):void

Writes an item at a given index.

Parameters

i:int — The index.
 
obj:* — The data.

toArray()method 
public function toArray():Array

Converts the collection into an array.

Returns
Array — An array.
toString()method 
public function toString():String

Prints out a string representing the current object.

Returns
String — A string representing the current object.