/*
 * @(#)Indexable.java	1.0 04/07/13
 */
 
/**
 * An interface for a generic container meant
 * for efficient insert, delete and search operations.
 */
public interface Indexable {
	
	/** Selects a field in x as the record's key */
	public Comparable getRecordKey(Object x);
	
	/** 
	 * Returns true if x is of a class that is the 
	 * intended extention of class Object in the
	 * current implementation of the container.
	 */
	public boolean validateRecordClass(Object x);
	
	/** Returns the total size of the container. */
	public long size();

	/** Returns the number of records in the container. */
	public long recordCount();	
	
	/** Checks if the container is empty */
	public boolean isEmpty();

	/**
	 * Inserts record x into the container. If x is
	 * already in the container, the existing record is updated by
	 * replacing it with x.
	 *
	 * @exception throws a ClassCastException if
	 *            validateRecord(x) is false.
	 */
	public void insert(Object x) throws ClassCastException;

	/**
	 * Deletes x from the container, where getRecordKey(x) = key.
	 *
	 * @return The object that was deleted from the container.
	 * @exception throws an IndexOutOfBoundsException if
	 *            the specified record is not in the container.
	 *	      NOTE: the exception's message MUST explain
	 *            the reason for throwing the excpetion. e.g.,
	 *            "Key = NNN is not in the tree."
	 */
	public Object delete(Comparable key) throws IndexOutOfBoundsException;

	/** 
	 * Returns an Object x such that getRecordKey(x) = key
	 * or null if there is no such a node.
	 */
	public Object search(Comparable key);
}

