dcapwell commented on code in PR #207:
URL: https://github.com/apache/cassandra-accord/pull/207#discussion_r2198651893


##########
accord-core/src/main/java/accord/utils/SortedArrays.java:
##########
@@ -1793,4 +1793,36 @@ private static void swap(int[] values, int i, int j)
         values[i] = values[j];
         values[j] = t;
     }
+
+    public static <T extends Comparable<? super T>> SimpleBitSet 
toSimpleBitSet(SortedArrays.SortedArrayList<T> superset,
+                                                                               
 SortedArrays.SortedArrayList<T> subset)
+    {
+        SimpleBitSet bitSet = new SimpleBitSet(superset.size());
+        int subsetIndex = 0;
+        for (int i = 0; i < superset.size(); i++)
+        {
+            long ri = SortedArrays.findNextIntersection(superset.array, i, 
subset.array, subsetIndex);
+            if (ri < 0)
+                break;
+            i = (int) (ri);
+            subsetIndex = (int) (ri >>> 32);
+
+            bitSet.set(i);
+        }
+        Invariants.require(bitSet.getSetBitCount() <= subset.size(), 
"Generated bit set is larger than the subset!");
+        return bitSet;
+    }
+
+    public static <T extends Comparable<? super T>> 
SortedArrays.SortedArrayList<T> 
fromSimpleBitSet(SortedArrays.SortedArrayList<T> superset,
+                                                                               
                      SimpleBitSet bitSet,
+                                                                               
                      IntFunction<T[]> alloc)
+    {
+        SortedArrays.SortedArrayList.Builder<T> builder = new 
SortedArrays.SortedArrayList.Builder<>(alloc.apply(bitSet.getSetBitCount()));
+        for (int i = 0; i < superset.size(); i++)

Review Comment:
   pushed and tests are passing



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to