jwutil.collections
Class SetUtil

java.lang.Object
  extended by jwutil.collections.SetUtil

public abstract class SetUtil
extends java.lang.Object

SetUtil

Version:
$Id: SetUtil.java 1934 2004-09-27 22:42:35Z joewhaley $
Author:
John Whaley

Constructor Summary
SetUtil()
           
 
Method Summary
static java.util.Collection powerSet(java.util.Collection c)
          The powerSet method returns a Collection whose elements are exactly the subsets of c, with no repetitions.
static java.util.Collection powerSet(CollectionFactory f, java.util.Collection c)
          The powerSet method returns a Collection whose elements are exactly the subsets of c, with no repetitions.
static java.util.Collection uniquify(java.util.Collection c)
          Given an input Collection that may contain duplicates returns a Collection with the same elements but no duplicates.
static java.util.Collection uniquify(CollectionFactory f, java.util.Collection c)
          Given an input Collection that may contain duplicates returns a Collection with the same elements but no duplicates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetUtil

public SetUtil()
Method Detail

powerSet

public static java.util.Collection powerSet(java.util.Collection c)
The powerSet method returns a Collection whose elements are exactly the subsets of c, with no repetitions. More precisely, if c is a Collection, possibly with repetitions, the result powerSet(c) is a Collection u without repetitions whose elements represent all the subsets of v. The powerset is stored in an ArrayList.

Parameters:
c - collection to take powerset of
Returns:
powerset of the given collection
See Also:
ArrayList, powerSet(CollectionFactory,Collection)

powerSet

public static java.util.Collection powerSet(CollectionFactory f,
                                            java.util.Collection c)
The powerSet method returns a Collection whose elements are exactly the subsets of c, with no repetitions. More precisely, if c is a Collection, possibly with repetitions, the result powerSet(c) is a Collection u without repetitions whose elements represent all the subsets of v.

Parameters:
f - collection factory to use to generate collection
c - collection to take powerset of
Returns:
powerset of the given collection

uniquify

public static java.util.Collection uniquify(java.util.Collection c)
Given an input Collection that may contain duplicates returns a Collection with the same elements but no duplicates. The resulting is returned in an ArrayList.

Parameters:
c - collection to uniquify
Returns:
uniquified version of collection
See Also:
ArrayList, uniquify(CollectionFactory,Collection)

uniquify

public static java.util.Collection uniquify(CollectionFactory f,
                                            java.util.Collection c)
Given an input Collection that may contain duplicates returns a Collection with the same elements but no duplicates. If c is already a Set, we just return a clone of it.

Parameters:
f - collection factory to use to generate collection
c - collection to uniquify
Returns:
uniquified version of collection


Copyright © 2004-2008 SUIF Compiler Group. All Rights Reserved.