ch.ethz.iks.util
Class CollectionUtils

java.lang.Object
  extended by ch.ethz.iks.util.CollectionUtils

public final class CollectionUtils
extends java.lang.Object

Collection utilities.

Since:
0.1
Author:
Jan S. Rellermeyer, ETH Zurich

Method Summary
static boolean addAllUnique(java.util.Collection collection, java.util.Collection values)
          add a collection of values to a collection.
static boolean addUnique(java.util.Collection collection, java.lang.Object value)
          add a unique value to a collection.
static void addValue(java.util.Map map, java.lang.Object key, java.lang.Object value)
          add a value to a value list in a Map.
static void addValue(java.util.Map map, java.lang.Object key, java.lang.Object value, int maxEntries)
          add a value to a value list in a Map that has a limited capacity.
static java.util.Collection difference(java.util.Collection c1, java.util.Collection c2)
           
static java.util.Collection intersection(java.util.Collection c1, java.util.Collection c2)
          the intersection of two collections.
static java.util.Collection leftDifference(java.util.Collection c1, java.util.Collection c2)
           
static void removeValue(java.util.Map map, java.lang.Object[] keys, java.lang.Object value)
          remove a value from a list in a Map.
static java.util.Collection rightDifference(java.util.Collection c1, java.util.Collection c2)
           
static java.util.Collection union(java.util.Collection c1, java.util.Collection c2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addUnique

public static boolean addUnique(java.util.Collection collection,
                                java.lang.Object value)
add a unique value to a collection. If the value already exists, it will return false.

Parameters:
collection - the collection.
value - the value.
Returns:
boolean.
Since:
0.1

addAllUnique

public static boolean addAllUnique(java.util.Collection collection,
                                   java.util.Collection values)
add a collection of values to a collection.

Parameters:
collection - the collection.
values - the values.
Returns:
boolean.
Since:
0.1

intersection

public static java.util.Collection intersection(java.util.Collection c1,
                                                java.util.Collection c2)
the intersection of two collections.

Parameters:
c1 - collection1.
c2 - collection2.
Returns:
the intersection, i.e. all elements that are in both collections.
Since:
0.1

union

public static java.util.Collection union(java.util.Collection c1,
                                         java.util.Collection c2)

rightDifference

public static java.util.Collection rightDifference(java.util.Collection c1,
                                                   java.util.Collection c2)

leftDifference

public static java.util.Collection leftDifference(java.util.Collection c1,
                                                  java.util.Collection c2)

difference

public static java.util.Collection difference(java.util.Collection c1,
                                              java.util.Collection c2)

addValue

public static void addValue(java.util.Map map,
                            java.lang.Object key,
                            java.lang.Object value)
add a value to a value list in a Map.

Parameters:
map - the map.
key - the key.
value - the value to be added to the list.
Since:
0.1

addValue

public static void addValue(java.util.Map map,
                            java.lang.Object key,
                            java.lang.Object value,
                            int maxEntries)
add a value to a value list in a Map that has a limited capacity. If the capacity is exceeded, the oldest entry is discarded.

Parameters:
map - the map.
key - the key.
value - the value to be added.
maxEntries - the capacity of the value list.
Since:
0.6

removeValue

public static void removeValue(java.util.Map map,
                               java.lang.Object[] keys,
                               java.lang.Object value)
remove a value from a list in a Map.

Parameters:
map - the map.
keys - the keys that are affected.
value - the value to be deleted in the lists.
Since:
0.1


Copyright © 2009 IKS, ETH Zurich. All Rights Reserved.