| 1 |
package com.carrotsearch.hppc.benchmarks.implementations; |
| 2 |
|
| 3 |
import it.unimi.dsi.fastutil.ints.IntOpenHashSet; |
| 4 |
|
| 5 |
import com.carrotsearch.hppc.benchmarks.IntSetOps; |
| 6 |
|
| 7 |
public class FastutilIntSetOps implements IntSetOps { |
| 8 |
private final IntOpenHashSet delegate; |
| 9 |
|
| 10 |
public FastutilIntSetOps(int expectedElements, double loadFactor) { |
| 11 |
this.delegate = new IntOpenHashSet(expectedElements, (float) loadFactor); |
| 12 |
} |
| 13 |
|
| 14 |
@Override |
| 15 |
public void add(int key) { |
| 16 |
delegate.add(key); |
| 17 |
} |
| 18 |
|
| 19 |
@Override |
| 20 |
public void bulkAdd(int[] keys) { |
| 21 |
for (int key : keys) { |
| 22 |
delegate.add(key); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
@Override |
| 27 |
public int bulkContains(int[] keys) { |
| 28 |
int v = 0; |
| 29 |
for (int key : keys) { |
| 30 |
if (delegate.contains(key)) { |
| 31 |
v++; |
| 32 |
} |
| 33 |
} |
| 34 |
return v; |
| 35 |
} |
| 36 |
|
| 37 |
@Override |
| 38 |
public int[] iterationOrderArray() { |
| 39 |
return delegate.toIntArray(); |
| 40 |
} |
| 41 |
} |