Class Index | File Index

Classes


Class Stack


Defined in: DataStructures.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Stack(args)
Class for managing a stack.
Field Summary
Field Attributes Field Name and Description
 
The list of the items in the stack.
Method Summary
Method Attributes Method Name and Description
 
allIndexesOf(item, callback)
Returns all the position in which the item has been found in the stack.
 
Removes all the items stored in the stack.
 
Clones the stack into a new stack.
 
Clones the stack into a new stack without cloning duplicated items.
 
contains(item, callback)
Checks if the stack contains an item that satisfy the condition represented by the callback function.
 
execute(callback)
Executes the callback function for each item of the stack.
 
filter(callback)
Returns the items that satisfy the condition determined by the callback.
 
getItem(index)
Returns the item at the position index.
 
Returns the iterator relative to the aggregate.
 
Returns the length of the stack.
 
indexOf(item, callback)
Returns the first position of the item in the stack.
 
Checks if the stack is empty.
 
lastIndexOf(item, callback)
Returns the last position of the item in the stack.
 
multiPop(times)
Removes the more item at the top of the stack.
 
multiPush(items)
Adds the items at the top of the stack.
 
peek()
Returns the item at the top of the stack without remove it.
 
pop()
Removes the item at the top of the stack.
 
push(item)
Adds the item at the top of the stack.
Class Detail
Stack(args)
Class for managing a stack.
Parameters:
{...*} args Optional
The items for initializing the stack.
Field Detail
items
The list of the items in the stack.
Method Detail
{Array} allIndexesOf(item, callback)
Returns all the position in which the item has been found in the stack.
Parameters:
item
{*} The item to search.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{Array} The positions in which the item has been found.

{void} clear()
Removes all the items stored in the stack.
Returns:
{void}

{Stack} clone()
Clones the stack into a new stack.
Returns:
{Stack} The stack cloned from this stack.

{Stack} cloneDistinct()
Clones the stack into a new stack without cloning duplicated items.
Returns:
{Stack} The stack cloned from this stack.

{boolean} contains(item, callback)
Checks if the stack contains an item that satisfy the condition represented by the callback function.
Parameters:
item
{*} The item to find.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{boolean} True if the stack contains the item that satisfy the condition, false otherwise.

{void} execute(callback)
Executes the callback function for each item of the stack. This method modifies the stack so if you don't need to modify it you must return the same item of the array.
Parameters:
callback
{function} The function to execute for each item. The function must accept the current item on which execute the function.
Returns:
{void}

{Array<*>} filter(callback)
Returns the items that satisfy the condition determined by the callback.
Parameters:
callback
{function} The function that implements the condition.
Returns:
{Array<*>} The array that contains the items that satisfy the condition.

{*} getItem(index)
Returns the item at the position index.
Parameters:
index
The position of the item.
Returns:
{*} The item at the position. It's undefined if index isn't in the stack bounds.

{Iterator} getIterator()
Returns the iterator relative to the aggregate.
Returns:
{Iterator} The iterator.

{Number} getLength()
Returns the length of the stack.
Returns:
{Number} The length of the stack.

{number} indexOf(item, callback)
Returns the first position of the item in the stack.
Parameters:
item
{*} The item to search.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{number} The first position of the item.

{boolean} isEmpty()
Checks if the stack is empty.
Returns:
{boolean} True if the stack is empty, false otherwise.

{number} lastIndexOf(item, callback)
Returns the last position of the item in the stack.
Parameters:
item
{*} The item to search.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{number} The last position of the item.

{Array<*>} multiPop(times)
Removes the more item at the top of the stack.
Parameters:
times
{number} The number of times to repeat the pop method.
Returns:
{Array<*>} The items at the top of the stack.

{void} multiPush(items)
Adds the items at the top of the stack.
Parameters:
items
{Array<*>} The items to add.
Returns:
{void}

{*} peek()
Returns the item at the top of the stack without remove it.
Returns:
{*} The item at the top of the stack. It's undefined if the stack is empty.

{*} pop()
Removes the item at the top of the stack.
Returns:
{*} The item at the top of the stack. It's undefined if the stack is empty.

push(item)
Adds the item at the top of the stack.
Parameters:
item
{*} The item to add. return {void}

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 23 2014 22:40:59 GMT+0200 (CEST)