coins.backend.util
Class BitMapSet

java.lang.Object
  extended bycoins.backend.util.BitMapSet
All Implemented Interfaces:
NumberSet

public class BitMapSet
extends java.lang.Object
implements NumberSet

Set of small integers represented in bit vector.


Nested Class Summary
static class BitMapSet.Iterator
           
 
Field Summary
(package private) static int WORDSIZE
           
 
Constructor Summary
BitMapSet()
          Create empty set.
BitMapSet(int size)
          Create set of given size
 
Method Summary
 void add(int x)
          Add integer x.
 void addAll(NumberSet x)
          Add all elements of another NumberSet x to this set.
 void addAllTo(NumberSet x)
          Add all elements of this set to another NumberSet x.
 void clear()
          Clear set
 java.lang.Object clone()
          Return copy of the object.
 boolean contains(int x)
          Return true if set has the integer x in it.
 void copy(NumberSet x)
          Copy another NumberSet x to this object.
 boolean equals(java.lang.Object x)
          Return true if x is same as this set.
 boolean exist(int x)
          Return true if set has the integer x in it.
 NumberSet.Iterator iterator()
          Enumerate all members.
 void join(BitMapSet x)
          Join operation.
static void main(java.lang.String[] argv)
          Unit test driver
 void meet(BitMapSet x)
          Meet operation.
 int nextElement(int from)
          Return an element greater than or equal to 'from'.
 void remove(int x)
          Remove integer x.
 void removeAll(NumberSet x)
          Remove all elements of another NumberSet x from this set.
 void removeAllFrom(NumberSet x)
          Remove all elements of this set from another NumberSet x.
 int size()
          Return the number of elements.
 void subtract(BitMapSet x)
          Subtract operation.
 void toArray(int[] a)
          Convert to array
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WORDSIZE

static final int WORDSIZE
See Also:
Constant Field Values
Constructor Detail

BitMapSet

public BitMapSet()
Create empty set.


BitMapSet

public BitMapSet(int size)
Create set of given size

Method Detail

size

public int size()
Return the number of elements.

Specified by:
size in interface NumberSet

clear

public void clear()
Clear set

Specified by:
clear in interface NumberSet

add

public void add(int x)
Add integer x.

Specified by:
add in interface NumberSet

remove

public void remove(int x)
Remove integer x.

Specified by:
remove in interface NumberSet

exist

public boolean exist(int x)
Return true if set has the integer x in it.


contains

public boolean contains(int x)
Return true if set has the integer x in it.

Specified by:
contains in interface NumberSet

copy

public void copy(NumberSet x)
Copy another NumberSet x to this object.

Specified by:
copy in interface NumberSet

addAll

public void addAll(NumberSet x)
Add all elements of another NumberSet x to this set.

Specified by:
addAll in interface NumberSet

addAllTo

public void addAllTo(NumberSet x)
Add all elements of this set to another NumberSet x.

Specified by:
addAllTo in interface NumberSet

join

public void join(BitMapSet x)
Join operation. Merge another BitMapSet x.


meet

public void meet(BitMapSet x)
Meet operation. Leave elements only those belong to both sets.


removeAll

public void removeAll(NumberSet x)
Remove all elements of another NumberSet x from this set.

Specified by:
removeAll in interface NumberSet

removeAllFrom

public void removeAllFrom(NumberSet x)
Remove all elements of this set from another NumberSet x.

Specified by:
removeAllFrom in interface NumberSet

subtract

public void subtract(BitMapSet x)
Subtract operation. Same as this.meet(x.complement)


nextElement

public int nextElement(int from)
Return an element greater than or equal to 'from'. Return -1 if there's no such thing.


iterator

public NumberSet.Iterator iterator()
Enumerate all members.

Specified by:
iterator in interface NumberSet

toArray

public void toArray(int[] a)
Convert to array

Specified by:
toArray in interface NumberSet

equals

public boolean equals(java.lang.Object x)
Return true if x is same as this set.

Specified by:
equals in interface NumberSet

clone

public java.lang.Object clone()
Description copied from interface: NumberSet
Return copy of the object.

Specified by:
clone in interface NumberSet

toString

public java.lang.String toString()

main

public static void main(java.lang.String[] argv)
Unit test driver