package com.jxml.quick.qmap;
import java.util.*;

/**
 * The key is a list of Comparable objects.
 */
public class QIndexedComparableList extends QComparableList
	implements Cloneable
{
	public QIndexMap container;

	public QIndexedComparableList(){}

	public QIndexedComparableList(Map container, List keyList)
	{
		super(container,keyList);
	}

	public void attach(Map container)
	{
		if (container instanceof QIndex)
		{
			this.container=(QIndexMap)container;
		}
		container.put(this,this);
	}

	/**
	 * Provides for reordering the keys in subclasses.
	 */
	public int index(int k)
	{
		if (container instanceof QIndex)
			return ((QIndex)container).index(k);
		else return k;
	}

	public void copy(Map newContainer)
	{
		try
		{
			QIndexedComparableList c=(QIndexedComparableList)super.clone();
			c.attach(newContainer);
		}
		catch (CloneNotSupportedException e)
		{
			throw new Error("wierdness");
		}
	}
}