/*
 * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*This js mainly concern with the data structures related to graphs*/

//////////////////////////////////////////////////////////////////////
//Buffer length

var BUFFER_LENGTH = 26;

function QueueForGraphs() {
    this.array = new Array();
}
function initQueue() {
    for (var i = 0 ; i < BUFFER_LENGTH ; i++) {
        this.array[i] = [i,0];
    }

}

function getData() {
    return this.array;
}

function addData(newValue) {

    //shift to left
    for(i = 0; i < BUFFER_LENGTH-1;i++) {
      this.array[i] = [i,this.array[i+1][1]];

    }
    //add the value to the last postion
    this.array[BUFFER_LENGTH-1] = [BUFFER_LENGTH-1,newValue];

}

QueueForGraphs.prototype.init = initQueue;
QueueForGraphs.prototype.get = getData;
QueueForGraphs.prototype.add = addData;



function test() {
var array = new Array();

var arrayObj = new QueueForGraphs(array);
arrayObj.init();
alert(arrayObj.get());
arrayObj.add(11);
alert(arrayObj.get());

arrayObj.add(12);
alert(arrayObj.get());
arrayObj.add(13);
alert(arrayObj.get());
arrayObj.add(14);
alert(arrayObj.get());
arrayObj.add(15);
alert(arrayObj.get());
arrayObj.add(16);
alert(arrayObj.get());

}
