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

/**
 * The key is a list of Comparable objects.
 */
public class QComparableList extends QComparable
{
	public List keyList=new ArrayList();

	public QComparableList(){}

	public QComparableList(Map container, List keyList)
	{
		this.keyList=keyList;
		attach(container);
	}

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

	public int compareTo(Object o)
	{
		QComparableList cl=(QComparableList)o;
		int i,s;
		s=keyList.size();
		for (i=0;i<s;++i)
		{
			int k=index(i);
			Comparable c0=(Comparable)keyList.get(k);
			Comparable c1=(Comparable)cl.keyList.get(k);
			int j=c0.compareTo(c1);
			if (j!=0)
				return j;
		}
		return 0;
	}
}