iglu.util
Class SetTools

java.lang.Object
  |
  +--iglu.util.SetTools

public class SetTools
extends java.lang.Object

Provides utility methods for dealing with Sets.

Version:
1.0
Author:
Ryan Scherle

Constructor Summary
private SetTools()
           
 
Method Summary
static void exportToFile(java.util.Set s, java.io.File file)
          Writes the set to a file, one item per line.
static java.util.Set importSet(java.io.File file)
          Converts a file into a set.
static java.util.Set intersection(java.util.Set first, java.util.Set second)
          Deprecated. use java.util.Set.retainAll(Collection) instead.
static void main(java.lang.String[] args)
          Runs some test examples on the methods of this class.
static void test()
          Runs some test examples on the methods of this class.
static java.util.Set union(java.util.Set first, java.util.Set second)
          Deprecated. use java.util.Set.addAll(Collection) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetTools

private SetTools()
Method Detail

union

public static java.util.Set union(java.util.Set first,
                                  java.util.Set second)
Deprecated. use java.util.Set.addAll(Collection) instead.

Returns the union of a two Sets. This operation does not affect either of the original sets. Note that the items within the sets are not cloned, so outside modifications may affect the contents of the set.

If the sets have differing implementations, the returned set has the same implementation as first. If first is a TreeSet, the set returned uses the same Comparator as first.

Throws:
java.lang.NullPointerException - if one of the two sets is null.

intersection

public static java.util.Set intersection(java.util.Set first,
                                         java.util.Set second)
Deprecated. use java.util.Set.retainAll(Collection) instead.

Returns the intersection of two Sets. This operation does not affect either of the original sets. Note that the items within the sets are not cloned, so outside modifications may affect the contents of the set.

If the sets have differing implementations, the returned set has the same implementation as first. If first is a TreeSet, the set returned uses the same Comparator as first.

Throws:
java.lang.NullPointerException - if one of the two sets is null.

importSet

public static java.util.Set importSet(java.io.File file)
                               throws java.io.FileNotFoundException
Converts a file into a set. Each line of the file becomes one element of the set.

java.io.FileNotFoundException

exportToFile

public static void exportToFile(java.util.Set s,
                                java.io.File file)
Writes the set to a file, one item per line.


test

public static void test()
Runs some test examples on the methods of this class.


main

public static void main(java.lang.String[] args)
Runs some test examples on the methods of this class.