We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 55d5510 commit ff1e4b2Copy full SHA for ff1e4b2
fastfilter/src/main/java/org/fastfilter/xor/Deduplicator.java
@@ -0,0 +1,27 @@
1
+package org.fastfilter.xor;
2
+
3
+import java.util.Arrays;
4
5
+public class Deduplicator {
6
7
+ /**
8
+ * Sorts the keys array and removes duplicates in place.
9
+ * Returns the new length of the array (number of unique elements).
10
+ *
11
+ * @param keys the array of keys to deduplicate
12
+ * @param length the current length of the array
13
+ * @return the new length after removing duplicates
14
+ */
15
+ public static int sortAndRemoveDup(long[] keys, int length) {
16
+ Arrays.sort(keys, 0, length);
17
+ int j = 1;
18
+ for (int i = 1; i < length; i++) {
19
+ if (keys[i] != keys[i - 1]) {
20
+ keys[j] = keys[i];
21
+ j++;
22
+ }
23
24
+ return j;
25
26
27
+}
0 commit comments