hmi.util
Class FilterSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.HashSet<E>
              extended by java.util.LinkedHashSet<E>
                  extended by hmi.util.FilterSet<E>
Type Parameters:
E - base type for the set
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>

public class FilterSet<E>
extends LinkedHashSet<E>

A FilterSet is an implementation of Set, based upon LinkedHashSet, that adds the filter(Predicate) method, and a map method.

Author:
Job Zwiers
See Also:
Serialized Form

Nested Class Summary
static interface FilterSet.Predicate<T>
          FilterSet.Predicates are Objects that implement a boolean test on Objects, in the form of their "valid" method.
static interface FilterSet.Transform<S,T>
          FilterSet.Transforms are objects that define a "mapping" from Objects to Object.
 
Field Summary
static long serialVersionUID
           
 
Constructor Summary
FilterSet()
          Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).
FilterSet(Collection<E> col)
          Constructs a new linked hash set with the same elements as the specified collection.
FilterSet(int initialCapacity)
          Constructs a new, empty linked hash set with the specified initial capacity and the default load factor (0.75).
FilterSet(int initialCapacity, float loadFactor)
          Constructs a new, empty linked hash set with the specified initial capacity and load factor.
 
Method Summary
 Iterator<E> filter(FilterSet.Predicate<E> pred)
          returns an Iterator for all Set elements that satisfy the given Predicate.
 void map(FilterSet.Transform<E,E> t)
          Transforms the set, by applying the given Transform on each Set element.
 
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

FilterSet

public FilterSet()
Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).


FilterSet

public FilterSet(Collection<E> col)
Constructs a new linked hash set with the same elements as the specified collection.


FilterSet

public FilterSet(int initialCapacity)
Constructs a new, empty linked hash set with the specified initial capacity and the default load factor (0.75).


FilterSet

public FilterSet(int initialCapacity,
                 float loadFactor)
Constructs a new, empty linked hash set with the specified initial capacity and load factor.

Method Detail

filter

public Iterator<E> filter(FilterSet.Predicate<E> pred)
returns an Iterator for all Set elements that satisfy the given Predicate.


map

public void map(FilterSet.Transform<E,E> t)
Transforms the set, by applying the given Transform on each Set element. The transformation is "in place", i.e., no Set elements are added or removed, but rather each element is modified by the Transform.