Packagede.polygonal.ds
Classpublic class LinkedStack
InheritanceLinkedStack Inheritance Object
Implements Collection

A stack based on a linked list. It's basically a wrapper class for a linked list to provide LIFO-like access.

See also

ArrayedStack


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

The total number of items.


Implementation
    public function get size():int
Constructor Detail
LinkedStack()Constructor
public function LinkedStack(list:DLinkedList = null)

Initializes a new stack. You can pass an existing doubly linked list to provide stack-like access.

Parameters
list:DLinkedList (default = null) — An existing list to become the stack.
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.
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:*):void

Pushes data onto the stack.

Parameters

obj:* — The data to insert.

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.