org.erights.e.elib.tables
Class ESet

java.lang.Object
  |
  +--org.erights.e.elib.tables.ESet
All Implemented Interfaces:
EPrintable, Iteratable, Marker, Persistent, Serializable
Direct Known Subclasses:
ConstSet, FlexSet, ROSet

public abstract class ESet
extends Object
implements EPrintable, Persistent, Iteratable

Untamed: A wrapper around an EMap, whose set-elements are the keys of the EMap.

XXX To be re-rationalized when we deprecate mutable collections. But introduced for now in order to remove 'Set' and its bretheren from Dean's transformer.

Author:
Mark S. Miller
See Also:
Serialized Form

Field Summary
(package private)  EMap myMap
          XXX Should build an ESet directly from a KeyColumn rather than an EMap.
(package private) static long serialVersionUID
           
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Constructor Summary
(package private) ESet(EMap map)
          Only subclasses within the package
 
Method Summary
 ConstSet and(ESet mask)
          Enabled: The intersection of the sets.
 ConstSet butNot(ESet mask)
          Enabled: The subset of this set not in 'mask'.
 boolean contains(Object candidate)
          Enabled: Is the candidate the same as any of the elements of the set?
 FlexSet diverge()
          Enabled: 'type' default to Object.class
 FlexSet diverge(Class type)
          Enabled: Returns a FlexSet whose initial state is a snapshot of the state of this set at the time of the diverge() request.
 Class elementType()
          Enabled: All elements of this set must be of this type.
 Object getElements()
          Enabled: Defaults to an array of elementType()
 Object getElements(Class elementType)
          Enabled: Returns a divergent array-of-type of all the values in order.
 boolean intersects(ESet other)
          Enabled: Do these sets have any elements in common?
 void iterate(AssocFunc func)
          Enabled: Call 'func' with each index-value pair in the set, in order.
 ConstSet or(ESet behind)
          Enabled: Defaults to not strict.
 ConstSet or(ESet behind, boolean strict)
          Enabled: Returns the union of the sets.
 void printOn(String left, String sep, String right, TextWriter out)
          Enabled: Onto out, print 'left' element0 'sep' ...
 ESet readOnly()
          Enabled: Returns a read-only facet on this set.
 int size()
          Enabled: How many entries are in the set?
 ConstSet snapshot()
          Enabled: Returns a ConstSet whose state is a snapshot of the state of this set at the time of the snapshot() request.
 ConstSet sort()
          Enabled: Returns a snapshot of this set, but reordered so the elements are in ascending order.
 ConstSet sort(CompFunc func)
          Enabled: Returns a snapshot of this set, but reordered so the elements are in ascending order according to func.
 String toString()
          Suppressed:
 ConstSet with(Object newElement)
          Enabled: Returns a ConstSet just like this one, except containing newElement.
 ConstSet without(Object element)
          Enabled: Returns a ConstSet just like this one, except that there is no ConstSet for 'key'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.erights.e.elib.oldeio.EPrintable
__printOn
 

Field Detail

serialVersionUID

static final long serialVersionUID

myMap

final EMap myMap
XXX Should build an ESet directly from a KeyColumn rather than an EMap.

Constructor Detail

ESet

ESet(EMap map)
Only subclasses within the package

Method Detail

snapshot

public ConstSet snapshot()
Enabled: Returns a ConstSet whose state is a snapshot of the state of this set at the time of the snapshot() request. A ConstSet returns itself.


readOnly

public ESet readOnly()
Enabled: Returns a read-only facet on this set. Someone holding this facet may see changes, but they cannot cause them.


diverge

public FlexSet diverge(Class type)
Enabled: Returns a FlexSet whose initial state is a snapshot of the state of this set at the time of the diverge() request.

Further changes to the original and/or the new set are independent -- they diverge.

The new set is constrained to only hold object of type 'type'. XXX 'type' should be declared as a ValueGuard rather than Class.


diverge

public FlexSet diverge()
Enabled: 'type' default to Object.class


contains

public boolean contains(Object candidate)
Enabled: Is the candidate the same as any of the elements of the set?


intersects

public boolean intersects(ESet other)
Enabled: Do these sets have any elements in common?


size

public int size()
Enabled: How many entries are in the set?


iterate

public void iterate(AssocFunc func)
Enabled: Call 'func' with each index-value pair in the set, in order.

Specified by:
iterate in interface Iteratable

or

public ConstSet or(ESet behind,
                   boolean strict)
Enabled: Returns the union of the sets.

If sets intersect, then if strict, throw an exception.

In the order, the 'behind' keys come first in their original order, then the receiver's remaining keys in their original order.


or

public ConstSet or(ESet behind)
Enabled: Defaults to not strict.


and

public ConstSet and(ESet mask)
Enabled: The intersection of the sets.

The order in the intersection is taken from the smaller of the original two. If they're the same size, then the receiver's order is used.


butNot

public ConstSet butNot(ESet mask)
Enabled: The subset of this set not in 'mask'.

The order is the order of the receiver, as modified by removal of the elements in mask in mask's order.


getElements

public Object getElements()
Enabled: Defaults to an array of elementType()


getElements

public Object getElements(Class elementType)
Enabled: Returns a divergent array-of-type of all the values in order.

XXX Should elementType be a ValueGuard rather than a Class?


with

public ConstSet with(Object newElement)
Enabled: Returns a ConstSet just like this one, except containing newElement.

The order is the same as the original; if 'newElement' is new, it is added to the end of the order.

Parameters:
newElement - nullOk;

without

public ConstSet without(Object element)
Enabled: Returns a ConstSet just like this one, except that there is no ConstSet for 'key'. The order is the same as the original, except that if 'key' was in the original, the last key in the ordering is moved into its place (as in the standard removal spec).

This is currently horribly inefficient. Can be made efficient by using backward deltas.

Parameters:
element - nullOk;

sort

public ConstSet sort()
Enabled: Returns a snapshot of this set, but reordered so the elements are in ascending order.


sort

public ConstSet sort(CompFunc func)
Enabled: Returns a snapshot of this set, but reordered so the elements are in ascending order according to func.


elementType

public Class elementType()
Enabled: All elements of this set must be of this type.

XXX This should return a ValueGuard rather than a Class


printOn

public void printOn(String left,
                    String sep,
                    String right,
                    TextWriter out)
             throws IOException
Enabled: Onto out, print 'left' element0 'sep' ... 'right'

IOException

toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?