/**
   The class ArrayPosition is used in the implementation of a list
   with a circular array and implements the interface Position.
   Each ArrayPosition contains an element and an index in the array.
  
   @author      Franck van Breugel
   @version     1.4    June 19, 2001
   @see ArrayList
*/
public class ArrayPosition implements Position 
{
    private Object element;      // element stored in this ArrayPosition
    private int index;           // index in the array of this ArrayPosition

    /**
       Constructs an ArrayPosition with specified element and index.
      
       @param element The element stored in the ArrayPosition.
       @param index The index in the array of the ArrayPosition.
    */
    public ArrayPosition(Object element, int index) 
    {
        this.element = element;
        this.index = index;
    }

    public Object element() 
    {
        return element;
    }

    /**
       Returns the index of this ArrayPosition.
      
       @return The index of this ArrayPosition.
    */
    public int getIndex() 
    {
        return index;
    }

    /**
       Sets the element stored in this ArrayPosition to the specified element.
      
       @param element The element to be stored in this ArrayPosition.
    */
    public void setElement(Object element) 
    {
        this.element = element;
    }

    /**
       Sets the index of this ArrayPosition to the specified index.
      
       @param index The index of this ArrayPosition.
    */
    public void setIndex(int index) 
    {
        this.index = index;
    }
}
