View Javadoc
1   /*
2    * Copyright (C) 2012 Alberto Irurueta Carro (alberto@irurueta.com)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.irurueta.sorting;
17  
18  import java.util.Comparator;
19  
20  /**
21   * This interface represents an object capable of comparing and averaging
22   * instances of type T.
23   *
24   * @param <T> Type to be compared and averaged.
25   */
26  public interface ComparatorAndAverager<T> extends Comparator<T> {
27  
28      /**
29       * Averages provided instances and returns an instance representing the
30       * average of provided ones. (i.e. if provided instances were doubles, then
31       * result would be 0.5 * (t1 + t2)).
32       *
33       * @param t1 Instance to be averaged.
34       * @param t2 Instance to be averaged.
35       * @return Instance representing average of provided ones.
36       */
37      T average(final T t1, final T t2);
38  }