org.jacaranda.verifier
Class Sets<E>

java.lang.Object
  extended by org.jacaranda.verifier.Sets<E>

public class Sets<E>
extends java.lang.Object

Implementation of sets used by the lexer and parser.

For the methods that take a 'consume' argument, when consume is true, the first Set argument to the method is modified in place. This can reduce memory usage, but requires the client to treat the first argument as being consumed by the operation.


Field Summary
 java.util.Set<E> empty
          An empty set.
 java.util.Set<E> undefined
          An undefined set that throws UnsupportedOperationException when used.
 
Constructor Summary
Sets()
           
 
Method Summary
 java.util.Set<E> clone(java.util.Set<E> A)
          Return a clone of A, that will not be consumed if A is.
 java.util.Set<E> difference(boolean consume, java.util.Set<E> A, java.util.Set<E> B)
          Return A \ B.
 java.util.Set<E> fromArray(E[] xs)
          Return a set containing all elements of the given array.
 boolean in(E x, java.util.Set<E> A)
          Return true iff x is an element of A.
 java.util.Set<E> intersect(boolean consume, java.util.Set<E> A, java.util.Set<E> B)
          Return A intersect B.
 boolean isEmpty(java.util.Set<E> A)
          Return true iff A is an empty set.
 java.util.Set<E> single(E x)
          Return a singleton set {x}.
 int size(java.util.Set<E> A)
          Return the number of elements in A.
 java.util.Set<E> union(boolean consume, java.util.Set<E> A, java.util.Set<E> B)
          Return A union B.
 java.util.Set<E> with(boolean consume, java.util.Set<E> A, E x)
          Return A if x is null, or A union {x} if x is nonnull.
 java.util.Set<E> without(boolean consume, java.util.Set<E> A, E x)
          Return A if x is null, or A \ {x} if x is nonnull.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

empty

public final java.util.Set<E> empty
An empty set.


undefined

public final java.util.Set<E> undefined
An undefined set that throws UnsupportedOperationException when used.

Constructor Detail

Sets

public Sets()
Method Detail

in

public boolean in(E x,
                  java.util.Set<E> A)
Return true iff x is an element of A.


size

public int size(java.util.Set<E> A)
Return the number of elements in A.


isEmpty

public boolean isEmpty(java.util.Set<E> A)
Return true iff A is an empty set.


union

public java.util.Set<E> union(boolean consume,
                              java.util.Set<E> A,
                              java.util.Set<E> B)
Return A union B. If 'consume' is true, A must be treated as consumed by the operation.


intersect

public java.util.Set<E> intersect(boolean consume,
                                  java.util.Set<E> A,
                                  java.util.Set<E> B)
Return A intersect B. If 'consume' is true, A must be treated as consumed by the operation.


with

public java.util.Set<E> with(boolean consume,
                             java.util.Set<E> A,
                             E x)
Return A if x is null, or A union {x} if x is nonnull. If 'consume' is true, A must be treated as consumed by the operation.


without

public java.util.Set<E> without(boolean consume,
                                java.util.Set<E> A,
                                E x)
Return A if x is null, or A \ {x} if x is nonnull. If 'consume' is true, A must be treated as consumed by the operation.


difference

public java.util.Set<E> difference(boolean consume,
                                   java.util.Set<E> A,
                                   java.util.Set<E> B)
Return A \ B. If 'consume' is true, A must be treated as consumed by the operation.


single

public java.util.Set<E> single(E x)
Return a singleton set {x}.


fromArray

public java.util.Set<E> fromArray(E[] xs)
Return a set containing all elements of the given array.


clone

public java.util.Set<E> clone(java.util.Set<E> A)
Return a clone of A, that will not be consumed if A is.