org.omnaest.utils.structure.collection
Class ComparatorUtils

java.lang.Object
  extended by org.omnaest.utils.structure.collection.ComparatorUtils

public class ComparatorUtils
extends Object

Helper for Comparator

Author:
Omnaest

Constructor Summary
ComparatorUtils()
           
 
Method Summary
static
<T> Comparator<T>
comparatorDecoratorUsingWeakHashMapCache(Comparator<T> comparator)
          Returns a Comparator decorator using an internal WeakHashMap to cache the comparison values returned from the given Comparator.
static
<T> Comparator<T>
comparatorUsingListIndexPosition(List<T> list)
          Returns a Comparator which uses List.indexOf(Object) to determine a comparing value for each element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComparatorUtils

public ComparatorUtils()
Method Detail

comparatorUsingListIndexPosition

public static <T> Comparator<T> comparatorUsingListIndexPosition(List<T> list)
Returns a Comparator which uses List.indexOf(Object) to determine a comparing value for each element. If a element is not present within the given List it is treated as being larger as an element being part of the List.

Parameters:
list -
Returns:

comparatorDecoratorUsingWeakHashMapCache

public static <T> Comparator<T> comparatorDecoratorUsingWeakHashMapCache(Comparator<T> comparator)
Returns a Comparator decorator using an internal WeakHashMap to cache the comparison values returned from the given Comparator. This speeds up Comparators which have a long running calculation to determine the comparison value.

Parameters:
comparator -
Returns:


Copyright © 2013. All Rights Reserved.