package de.lmu.ifi.dbs.data;

import java.util.BitSet;
import java.util.Comparator;

/**
 * @author Arthur Zimek (<a href="mailto:zimek@dbs.ifi.lmu.de">zimek@dbs.ifi.lmu.de</a>)
 */
public class BitSetComparator implements Comparator<BitSet>
{

    /**
     * 
     * @see java.util.Comparator#compare(T, T)
     */
    public int compare(BitSet b1, BitSet b2)
    {
        if(b1.size() > b2.size())
        {
            return -1;
        }
        else if(b2.size() > b1.size())
        {
            return 1;
        }
        else
        {            
            int i1 = 0;
            int i2 = 0;
            while((i1 = b1.nextSetBit(i1)) >= 0 && (i2 = b2.nextSetBit(i2)) >= 0)
            {
                if(i1 < i2)
                {
                    return -1;
                }
                else if(i2 < i1)
                {
                    return 1;
                }
            }
        }
        return 0;
    }

}

@@ -381,17 +381,17 @@
 .size() 
-%3E
+%3C
  b2.size
@@ -454,17 +454,17 @@
 lse if(b
-2
+1
 .size() 
@@ -466,17 +466,17 @@
 ze() %3E b
-1
+2
 .size())
@@ -619,17 +619,66 @@
   while(
-(
+i1 %3E= 0 && i2 %3E= 0)%0A            %7B%0A                
 i1 = b1.
@@ -695,19 +695,26 @@
 (i1)
-) %3E= 0 && (
+;%0A                
 i2 =
@@ -735,29 +735,9 @@
 (i2)
-) %3E= 0)%0A            %7B
+;
 %0A   
@@ -857,14 +857,14 @@
 if(i
-2 %3C i1
+1 %3E i2
 )%0A  

order corrected