Pages

Thursday, December 23, 2010

Simple Stack Data Structure

/**
 * Simple List
 * @author : irfanudin ridho
 * @email  : irfan.ub@gmail.com
 * @date   : December 24, 2010
 * @version: 1.0
 *
 * This class provide a stack equivalent data structure
 */


function SimpleStack(){
    this.data = new Array();
}


/*
 * @param string,number,boolean data item in data structure
 */
SimpleStack.prototype.push = function(data){
    var len = this.data.length;
    this.data[len] = data;
}


/*
 * @return string,number,boolean last item
 */
SimpleStack.prototype.pop = function(){
    var len = this.data.length;
    return this.data[len-1];
}

No comments:

Post a Comment