next up previous
Next: CallDebugger Up: simlib Previous: BitPackClass

BitSetClass


     NAME
	  bitsetclass -	set of numbers.

     DESCRIPTION
	  This class implements	a bounded set of integers.

     AUTHOR
	  Boris	Magnusson, Lund	University.

     EXAMPLE
	     external class BitSetClass;
	     ref(BitSetClass) s1,s2;
	     s1:-new BitSetClass(47); !	-- 48 possible members 0,1,...
	  47 --;
	     s1.addMember(22);	      !	-- make	22 member of the set
	  --;
	     s2:-s1.SetCopy.SetNot;   !	-- s2 holds the	ones not
	  Members of s1	--;

     DETAILED INTERFACE
	     BitFiddleClass class BitSetClass(MaxSet);
	     integer MaxSet;
	  BitSetClass is set of	integers, compatcly represented.   The
	  members  are	numbers	 0,1,...,MaxMember. MaxMember is given
	  when an object of this class is created.

	  Supers: BitFiddleClass
	  Kind:	Instantiable
	  Init:	none
	  Sequencing: (MaxMember AddMember RemoveMember	isMember
	  FirstMember SetClear SetNot SetCopy SetUnion	SetCut
	  SetEqual LoadFromArray StoreToArray)*

     OPERATIONS
     MaxMember
	  Returns the highest member number in this set	(=MaxSet).

     AddMember
	     procedure AddMember(number);
	     integer Number;
	  Include Number in the	set. If	Number is outside 0..MaxMember
	  the call is ignored.

     RemoveMember
	     procedure RemoveMember(Number);
	     integer Number;
	  Remove Number	from the set if	a member. If Numer is  outside
	  0..MaxMember the call	is ignored.

     isMember
	     Boolean procedure isMember(number);
	     integer Number;

	  Return True if Number	is member of the set, False otherwise.
	  If Number is outside 0..MaxMember it also returns False.

     FirstMember
	     integer procedure FirstMember;
	  Return the lowest Number of a	member in the set.  Returns -1
	  for an empty set.

     SetClear
	     procedure SetClear;
	  Make the set contain no members.

     SetNot
	     procedure SetNot;
	  Make the set contain exactly those Numbers  that  where  not
	  members before.

     SetCopy
	     ref(bitsetClass) procedure	SetCopy;
	  Return a copy	of the set that	 initally  contains  the  same
	  Members.

     SetUnion
	     procedure SetUnion(otherSet);
	     ref(bitSetClass) otherSet;
	  Make the set conatain	also those Numbers that	are members of
	  another  Set.	 Numbers of otherSet, outside 0..MaxMembers of
	  this Set are not considered.

     SetCut
	     procedure SetCut(otherSet);
	     ref(bitSetClass) otherSet;
	  Make this set	contain	only those Numbers that	 initally  are
	  members of both sets.

     SetEqual
	     Boolean procedure SetEqual(otherSet);
	     ref(bitSetClass) otherSet;
	  Return true if both sets contain the same  members.  If  the
	  two  sets are	of different size they are considered equal if
	  the corresponding parts are equal and	the extension part  of
	  the larger set is empty.

     LoadFromArray
	     procedure LoadFromArray(ar);
	     integer array ar;
	  Regard an integer array as a set member representation where
	  the most significant bit of the first	element	corresponds to
	  member O and so on.  Make  the  set  contain	exactly	 those
	  members  where  there	 is a bit=1 in the integer array. Bits
	  outside the range 0..MaxMembers are not included.

     StoreToArray
	     procedure StoreToArray(ar);
	     integer array ar;
	  Regard an integer array as a set member representation where
	  the most significant bit of the first	element	corresponds to
	  member O and so on.  Set  the	 bits  in  the	integer	 array
	  corresponding	 to  the  members  of the set. The set will be
	  truncated if the array is too	short.