/** * Creates a new <code>TIntHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>int</code> primitives */ public TIntHashSet(int[] array) { this(array.length); addAll(array); }
/** * Creates a new <code>TIntHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>int</code> primitives * @param strategy used to compute hash codes and to compare keys. */ public TIntHashSet(int[] array, TIntHashingStrategy strategy) { this(array.length, strategy); addAll(array); }
@Override protected void addPosting(Posting p) { super.addPosting(p); positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void addPosting(Posting p) { super.addPosting(p); positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void addPosting(Posting p) { super.addPosting(p); positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void addPosting(Posting p) { super.addPosting(p); positions.addAll(((BlockPosting)p).getPositions()); }
/** * return intersection between two int[] * @param arr1 * @param arr2 * @return intersection */ public static int[] intersection(int[] arr1, int[] arr2) { TIntHashSet set = new TIntHashSet(); set.addAll(arr1); Arrays.sort(arr2); TIntArrayList list = new TIntArrayList(); for (int i : arr2) { if (set.contains(i)) { list.add(i); } } return list.toNativeArray(); }
/** * return intersection between two int[] * @param arr1 * @param arr2 * @return intersection */ public static int[] intersection(int[] arr1, int[] arr2) { TIntHashSet set = new TIntHashSet(); set.addAll(arr1); Arrays.sort(arr2); TIntArrayList list = new TIntArrayList(); for (int i : arr2) { if (set.contains(i)) { list.add(i); } } return list.toNativeArray(); }
/** * * @param nodes A set of nodes in a tree * @param searched If non-null, a list which will be populated with indices of the nodes that have been searched * @return The nearest (deepest) common ancestor among a set of nodes, which may belong to that set; or null if there is no common ancestor (should not occur if a tree) * @author Nathan Schneider (nschneid) */ public static <T extends TreeNode<T>> T nearestCommonAncestor(Set<T> nodes, TIntHashSet searched) { TIntHashSet alreadySearched = searched; if (searched==null) alreadySearched = new TIntHashSet(); T best = null; int i = 0; for (T next : nodes) { if (i++==0) { best = next; continue; } TIntHashSet srched = new TIntHashSet(); best = best.nearestCommonAncestorWith(next, srched, alreadySearched); if (best==null) break; alreadySearched.addAll(srched.toArray()); } return best; }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
n2 = that.getAncestorAtLevel(this.depth, ancPath, alreadySearched); if (searched!=null) searched.addAll(ancPath.toNativeArray()); if (alreadySearched!=null && (n2==that || alreadySearched.contains(n2.index))) return (T)this; n2 = this.getAncestorAtLevel(that.depth, ancPath); if (searched!=null) searched.addAll(ancPath.toNativeArray());
hIndices.addAll(indices);
hIndices.addAll(indices);
hIndices.addAll(indices);
hIndices.addAll (indices);