org.abora.white.collection.sets
Class ImmuSet

java.lang.Object
  |
  +--org.abora.white.xpp.basic.Heaper
        |
        +--org.abora.white.collection.sets.ScruSet
              |
              +--org.abora.white.collection.sets.ImmuSet
Direct Known Subclasses:
EmptyImmuSet, ImmuSetOnMu, TinyImmuSet

public abstract class ImmuSet
extends ScruSet

ImmuSets are ScruSets which are guaranteed never to change. ImmuSets correspond to the mathematical notion of a finite set of elements, except of course that here the elements can be any valid X++ object. Just like mathematical sets, two are equal (according to isEqual) iff they have the same elements. Just because the set cannot change, that doesn't prevent any of the members from undergoing state change.

ImmuSets implement some additional protocol to make new sets out of old ones according to the familiar set theoretic operators (like intersect). XuRegions are much like ImmuSets of Positions except that they aren't necessarily finite or even enumerable. XuRegions implement a similar protocol, but aren't polymorphic with ImmuSets.


Field Summary
protected static ImmuSet EmptySet
           
 
Constructor Summary
protected ImmuSet()
           
protected ImmuSet(Rcvr rcvr)
           
 
Method Summary
 int actualHashForEqual()
          Defined by subclasses to produce the value returned by hashForEqual.
 ImmuSet asImmuSet()
          Return an immu snapshot of my current state.
abstract  MuSet asMuSet()
          Return a Mu whose initial state is the same as my current state, but which will now deviate independently of me.
 ScruSet copy()
          don't need to actually make a copy, as this is immutable
abstract  IntegerValue count()
          How many elements are currently in the set.
protected static ImmuSet from(MuSet set)
          This is for ImmuSet subclasses to produce results from temporary MuSets.
abstract  boolean hasMember(Heaper someone)
          Is someone a member of the set now?
abstract  ImmuSet intersect(ScruSet another)
          Regular set intersection.
abstract  boolean isEmpty()
          Return true if this set does not currently have any elements.
 boolean isEqual(Heaper other)
          Return true if the two objects are equal.
static ImmuSet make()
           
static ImmuSet make(MuSet set)
           
abstract  ImmuSet minus(ScruSet another)
          Return an ImmuSet containing those of my members which aren't members of 'another'
static ImmuSet newWith(Heaper value)
          A single element ImmuSet
abstract  Stepper stepper()
          Returns a stepper which will enumerate all the elements of the set in some unspecified order
abstract  ImmuSet unionWith(ScruSet another)
          Return an ImmuSet containing those objects with are members of either of us
abstract  ImmuSet with(Heaper anElement)
          'set->with (anElement)' means the same as 'set->unionWith (immuSet (anElement))'.
abstract  ImmuSet without(Heaper anElement)
          'set->without (anElement)' means the same as 'set->minus (immuSet (anElement))'.
 
Methods inherited from class org.abora.white.collection.sets.ScruSet
asArray, contentsEqual, contentsHash, intersects, isSubsetOf, printOn, printOnWithSimpleSyntax, printOnWithSyntax, theOne
 
Methods inherited from class org.abora.white.xpp.basic.Heaper
destroy, destruct, equals, hashForEqual, printContentsOn, sendSelfTo, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EmptySet

protected static ImmuSet EmptySet
Constructor Detail

ImmuSet

protected ImmuSet()

ImmuSet

protected ImmuSet(Rcvr rcvr)
Method Detail

from

protected static ImmuSet from(MuSet set)
This is for ImmuSet subclasses to produce results from temporary MuSets. The difference between this and ImmuSet make.MuSet: is that this doesn't make a copy of the MuSet when making an ImmuSetOnMu.


make

public static ImmuSet make()

make

public static ImmuSet make(MuSet set)

newWith

public static ImmuSet newWith(Heaper value)
A single element ImmuSet


hasMember

public abstract boolean hasMember(Heaper someone)
Description copied from class: ScruSet
Is someone a member of the set now?

Specified by:
hasMember in class ScruSet

isEmpty

public abstract boolean isEmpty()
Description copied from class: ScruSet
Return true if this set does not currently have any elements.

Specified by:
isEmpty in class ScruSet
Returns:
true if this set does not currently have any elements.

intersect

public abstract ImmuSet intersect(ScruSet another)
Regular set intersection. Return an ImmuSet containing only those objects which are members of both sets


minus

public abstract ImmuSet minus(ScruSet another)
Return an ImmuSet containing those of my members which aren't members of 'another'


unionWith

public abstract ImmuSet unionWith(ScruSet another)
Return an ImmuSet containing those objects with are members of either of us


with

public abstract ImmuSet with(Heaper anElement)
'set->with (anElement)' means the same as 'set->unionWith (immuSet (anElement))'. It returns an ImmuSet with all my members and having anElement as a member. If anElement is a member of me, then the result is identical to me.


without

public abstract ImmuSet without(Heaper anElement)
'set->without (anElement)' means the same as 'set->minus (immuSet (anElement))'. It returns an ImmuSet with all my members except anElement. If anElement isn't already a member, then the result is identical to me.


copy

public ScruSet copy()
don't need to actually make a copy, as this is immutable

Specified by:
copy in class ScruSet

asImmuSet

public ImmuSet asImmuSet()
Description copied from class: ScruSet
Return an immu snapshot of my current state. Should probably be done with a Converter rather than with a message (for the reasons listed in the Converter class comment). In terms of the Stamp/Bert analogy mentioned in the class comment, asImmuSet is like asking for the current Stamp.

Specified by:
asImmuSet in class ScruSet

asMuSet

public abstract MuSet asMuSet()
Description copied from class: ScruSet
Return a Mu whose initial state is the same as my current state, but which will now deviate independently of me. In terms of the Stamp/Bert analogy mentioned in the class comment, asMuSet is like asking for a new Bert starting on the current Stamp.

Specified by:
asMuSet in class ScruSet

count

public abstract IntegerValue count()
Description copied from class: ScruSet
How many elements are currently in the set. Being a set, if the same element is put into the set twice, it is only in the set once. 'Same' above is according to 'isEqual'.

Specified by:
count in class ScruSet

stepper

public abstract Stepper stepper()
Description copied from class: ScruSet
Returns a stepper which will enumerate all the elements of the set in some unspecified order

Specified by:
stepper in class ScruSet

actualHashForEqual

public int actualHashForEqual()
Description copied from class: Heaper
Defined by subclasses to produce the value returned by hashForEqual.

Overrides:
actualHashForEqual in class ScruSet

isEqual

public boolean isEqual(Heaper other)
Description copied from class: Heaper
Return true if the two objects are equal.

Specified by:
isEqual in class ScruSet


Copyright © 2003 David G Jones. All Rights Reserved.
Original Udanax-Gold - Copyright © 1979-1999 Udanax.com. All rights reserved.