Java Code Examples for gnu.trove.set.TIntSet#retainAll()
The following examples show how to use
gnu.trove.set.TIntSet#retainAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FuzzySetSimJoin.java From JedAIToolkit with Apache License 2.0 | 5 votes |
private static float jaccard(int[] r, int[] s) { TIntSet nr = new TIntHashSet(r); TIntSet ns = new TIntHashSet(s); TIntSet intersection = new TIntHashSet(nr); intersection.retainAll(ns); TIntSet union = new TIntHashSet(nr); union.addAll(ns); return ((float) intersection.size()) / ((float) union.size()); }
Example 2
Source File: WeightedOverlap.java From ADW with GNU General Public License v3.0 | 5 votes |
public double compare(SemSig v1, SemSig v2, boolean sortedNormalized) { TIntSet overlap = new TIntHashSet(v1.getVector().keySet()); overlap.retainAll(v2.getVector().keySet()); return compare(overlap, v1.getSortedIndices(), v2.getSortedIndices()); }
Example 3
Source File: WeightedOverlap.java From ADW with GNU General Public License v3.0 | 5 votes |
public double compare( TIntFloatMap v1, TIntFloatMap v2, boolean sorted) { TIntSet overlap = new TIntHashSet(v1.keySet()); overlap.retainAll(v2.keySet()); return compare(overlap, SemSigUtils.getSortedIndices(v1), SemSigUtils.getSortedIndices(v2)); }
Example 4
Source File: ArrayUtils.java From htm.java with GNU Affero General Public License v3.0 | 3 votes |
/** * Test whether each element of a 1-D array is also present in a second * array. * * Returns a int array whose length is the number of intersections. * * @param ar1 the array of values to find in the second array * @param ar2 the array to test for the presence of elements in the first array. * @return an array containing the intersections or an empty array if none are found. */ public static int[] in1d(int[] ar1, int[] ar2) { if(ar1 == null || ar2 == null) { return EMPTY_ARRAY; } TIntSet retVal = new TIntHashSet(ar2); retVal.retainAll(ar1); return retVal.toArray(); }