LIFO Data structure
Extends Instance PropertiesProperty | Type | Default Value | Description |
count | Number | the current number of elements in this queue | |
isEmpty | Boolean | true if this queue is empty | |
values | Array | a copy of the values contained in this queue | |
Removes all items from this stack.
Source
- function (){
- this.__stack.length = 0;
- this.__next = -1;
- }
Determine if this stack contains the element
Argumentsthe object to find
Boolean
true if this stack contains the element
- function (obj){
- return this.__stack.indexOf(obj) !== -1;
- }
Retrieves the item at the tail of the stack without removing it
Returns*
The element at the tail of the stack. Returns undefined if the stack is empty.
- function (){
- var next = this.__next,
- ret;
- if (next >= 0) {
- ret = this.__stack[next];
- }
- return ret;
- }
Removes the tail of this static
Returns*
the data at the tail of this stack
- function (){
- var next = this.__next,
- ret,
- stack;
- if (next >= 0) {
- stack = this.__stack;
- ret = stack[next];
- stack[this.__next--] = undefined;
- }
- return ret;
- }
Add an item to the tail of this stack
Argumentsitem to qppend to this stack
- function (data){
- this.__stack[++this.__next] = data;
- }
Removes an element from this stack.
Argumentsthe data to remove.
Boolean
true if the element was removed, false otherwise.
- function (obj){
- var index = this.__stack.indexOf(obj), ret = false;
- if (index !== -1) {
- if (index === this.__next) {
- this.pop();
- } else {
- this.__stack.splice(index, 1);
- this.__next--;
- }
- ret = true;
- }
- return ret;
- }
MIT https://github.com/C2FO/comb/raw/master/LICENSE
git clone git://github.com/C2FO/comb.git