Skip to content

Commit ff1e4b2

Browse files
committed
adding missing file
1 parent 55d5510 commit ff1e4b2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)