2 *******************************************************************************
\r
3 * Copyright (C) 2009, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
7 package com.ibm.icu.impl;
\r
9 import java.util.Comparator;
\r
11 public class MultiComparator<T> implements Comparator<T> {
\r
12 private Comparator<T>[] comparators;
\r
14 public MultiComparator (Comparator<T>... comparators) {
\r
15 this.comparators = comparators;
\r
18 /* Lexigraphic compare. Returns the first difference
\r
19 * @return zero if equal. Otherwise +/- (i+1)
\r
20 * where i is the index of the first comparator finding a difference
\r
21 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
\r
23 public int compare(T arg0, T arg1) {
\r
24 for (int i = 0; i < comparators.length; ++i) {
\r
25 int result = comparators[i].compare(arg0, arg1);
\r