dcapwell commented on code in PR #207:
URL: https://github.com/apache/cassandra-accord/pull/207#discussion_r2191090639
##########
accord-core/src/main/java/accord/utils/SortedArrays.java:
##########
@@ -1793,4 +1794,29 @@ private static void swap(int[] values, int i, int j)
values[i] = values[j];
values[j] = t;
}
+
+ public static <T extends Comparable<? super T>> BitSet
toBitSet(SortedArrays.SortedArrayList<T> src,
+
SortedArrays.SortedArrayList<T> subset)
+ {
+ BitSet bitSet = new BitSet(src.size());
+ for (int i = 0; i < src.size(); i++)
+ {
+ if (subset.contains(src.get(i)))
Review Comment:
> we should use foldlIntersection for O(n) versus O(n.lg(n)) complexity
Can you explain where this `lg(n)` is coming from?
```java
for (int i = 0; i < superset.size(); i++)
```
We are looping, so `O(N)` on that
We then call `accord.utils.SimpleBitSet#get`
```java
int index = indexOf(i);
long bit = bit(i);
return 0 != (bits[index] & bit);
```
which should be `O(1)`
We then call
```java
builder.add(superset.get(i));
```
`add` is `O(1)` and `get` is also `O(1)`
--
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]