dsto.dfc.collections
Class DfcCollections

java.lang.Object
  extended by dsto.dfc.collections.DfcCollections

public final class DfcCollections
extends Object

Miscellaneous utilities for use with the Java Collections classes.

Version:
$Revision$
Author:
Matthew Phillips

Method Summary
static boolean arraysEqual(int[] a1, int[] a2)
          Test whether two int arrays are equal.
static boolean arraysEqual(Object[] a1, Object[] a2)
           
static int compareArrays(Object[] a1, Object[] a2)
          Compare the contents of two arrays.
static boolean containsAny(Collection source, Collection coll)
          Test if one collection contains any element from another.
static boolean containsAny(Collection source, Collection coll, Comparator comparator)
          Test if one collection contains any element from another.
static int findSortedIndex(List items, Object item)
          Find the index that an item should have in a sorted list to maintain the sorted order.
static int findSortedIndex(List items, Object item, Comparator comparator)
          Find the index that an item should have in a sorted list to maintain the sorted order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findSortedIndex

public static int findSortedIndex(List items,
                                  Object item)
Find the index that an item should have in a sorted list to maintain the sorted order. The items in the list are assumed to be Comparable.

Parameters:
items - A sorted list of items.
item - The item.

findSortedIndex

public static int findSortedIndex(List items,
                                  Object item,
                                  Comparator comparator)
Find the index that an item should have in a sorted list to maintain the sorted order.

Parameters:
items - A sorted list of items.
item - The item.
comparator - The comparator used to order the list.

compareArrays

public static int compareArrays(Object[] a1,
                                Object[] a2)
                         throws IllegalArgumentException
Compare the contents of two arrays. The contents must implement the Comparable interface.

Parameters:
a1 - The first array.
a2 - The second array.
Returns:
< 0 if a1 < a2, 0 if a1 == a2, > 0 if a1 > a2.
Throws:
IllegalArgumentException - if any of the elements in a1 or a2 are found not to be Comparable.

arraysEqual

public static boolean arraysEqual(int[] a1,
                                  int[] a2)
Test whether two int arrays are equal.


arraysEqual

public static boolean arraysEqual(Object[] a1,
                                  Object[] a2)

containsAny

public static boolean containsAny(Collection source,
                                  Collection coll)
Test if one collection contains any element from another.

Returns:
True if any element of coll is in source.
See Also:
containsAny(Collection, Collection, Comparator)

containsAny

public static boolean containsAny(Collection source,
                                  Collection coll,
                                  Comparator comparator)
Test if one collection contains any element from another.

Returns:
True if any element of coll is in source, using comparator to test for equality.


Copyright © 2008 Commonwealth of Australia