/* * @(#) Indexable.java - Read-only interface for indexed containers. * (c) 2000 Ivan Maidanski http://ivmai.chat.ru * Freeware class library sources. All rights reserved. ** * Language: Java [pure] * Tested with: JDK v1.1.6 * Last modified: 2000-12-23 21:25:00 GMT+03:00 */ /* * This software is the proprietary information of the author. ** * Permission to use, copy, and distribute this software and its * documentation for non-commercial purposes and without fee is * hereby granted provided that this copyright notice appears in all * copies. ** * This software should not be modified in any way; any found bug * should be reported to the author. ** * The author disclaims all warranties with regard to this software, * including all implied warranties of merchantability and fitness. * In no event shall the author be liable for any special, indirect * or consequential damages or any damages whatsoever resulting from * loss of use, data or profits, whether in an action of contract, * negligence or other tortuous action, arising out of or in * connection with the use or performance of this software. */ package ivmai.util; /** * Read-only interface for indexed containers. ** * This interface should be implemented by a class that contains a * group of (typed) elements and allows at least read-only access to * these elements by an integer index (from 0 to * length() - 1, inclusive). ** * @version 2.0 * @author Ivan Maidanski ** * @since 2.0 */ public interface Indexable { /** * Returns the number of elements in this container. ** * This method should not be final. ** * @return * amount (non-negative value) of elements. ** * @see #getAt(int) */ public abstract int length(); /** * Returns value of the element at the specified index. ** * If the value to return is primitive then it is being wrapped. * This method should not be final. ** * @param index * the index (must be in the range) at which to return an element. * @return * an element (may be null) at index. * @exception ArrayIndexOutOfBoundsException * if index is negative or is not less than * length(). * @exception OutOfMemoryError * if there is not enough memory. ** * @see #length() */ public abstract Object getAt(int index) throws ArrayIndexOutOfBoundsException; }