1 /* 2 * Copyright 2010 Daniel Kurka 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 package com.googlecode.mgwt.collection.shared; 17 18 /** 19 * A light array implements the same interface as a javascript array. 20 * 21 * @author Daniel Kurka 22 * 23 * @param <T> the type of object to store 24 */ 25 public interface LightArray<T> { 26 27 /** 28 * get the object at a specific index 29 * 30 * @param index the index 31 * @return the object or null 32 */ 33 public T get(int index); 34 35 /** 36 * put an object to a given index. the array autoexpands and fills up missing values with null 37 * 38 * @param index the index 39 * @param value the value to store 40 */ 41 public void set(int index, T value); 42 43 /** 44 * the length of the array 45 * 46 * @return the length of the array 47 */ 48 public int length(); 49 50 /** 51 * push a value on to the array 52 * 53 * @param value 54 */ 55 void push(T value); 56 57 /** 58 * pop a value from the array 59 * 60 * @return the value 61 */ 62 public T shift(); 63 64 /** 65 * push a value onto the array 66 * 67 * @param value to push 68 */ 69 public void unshift(T value); 70 71 }