/** * Creates a new tree set copying the elements of an array. * * @param a * an array to be copied into the new tree set. */ public IntRBTreeSet(final int[] a) { this(); int i = a.length; while (i-- != 0) add(a[i]); } /**
/** * Creates a new tree set copying the elements of an array using a given * {@link Comparator}. * * @param a * an array to be copied into the new tree set. * @param c * a {@link Comparator} (even better, a type-specific comparator). */ public IntRBTreeSet(final int[] a, final Comparator<? super Integer> c) { this(c); int i = a.length; while (i-- != 0) add(a[i]); } /*
@Override public boolean add(final int k) { if (!in(k)) throw new IllegalArgumentException("Element (" + k + ") out of range [" + (bottom ? "-" : String.valueOf(from)) + ", " + (top ? "-" : String.valueOf(to)) + ")"); return IntRBTreeSet.this.add(k); } @Override
/** * Creates a new tree set and fills it with the elements of a given array using * a given {@link Comparator}. * * @param a * an array whose elements will be used to fill the set. * @param offset * the first element to use. * @param length * the number of elements to use. * @param c * a {@link Comparator} (even better, a type-specific comparator). */ public IntRBTreeSet(final int[] a, final int offset, final int length, final Comparator<? super Integer> c) { this(c); IntArrays.ensureOffsetLength(a, offset, length); for (int i = 0; i < length; i++) add(a[offset + i]); } /**
private static IntSet readQueryDoc(File queryDoc) throws IOException { if (queryDoc == null) { return new IntRBTreeSet(); } final DataInputStream in = new DataInputStream(new FileInputStream(queryDoc)); final IntRBTreeSet querySet = new IntRBTreeSet(); while (true) { try { querySet.add(in.readInt()); } catch (EOFException x) { break; } } return querySet; }
/** * Creates a new tree set using elements provided by a type-specific iterator. * * @param i * a type-specific iterator whose elements will fill the set. */ public IntRBTreeSet(final IntIterator i) { while (i.hasNext()) add(i.nextInt()); } /**
public static int[] mapUID(long[] uidArray, DocIDMapper mapper) { IntRBTreeSet idSet = new IntRBTreeSet(); for (long uid : uidArray) { if (uid != ZoieSegmentReader.DELETED_UID) { int docid = mapper.getDocID(uid); if (docid != DocIDMapper.NOT_FOUND) { idSet.add(docid); } } } return idSet.toIntArray(); }
public static int[] mapUID(long[] uidArray, DocIDMapper mapper) { IntRBTreeSet idSet = new IntRBTreeSet(); for (long uid : uidArray) { if (uid != ZoieSegmentReader.DELETED_UID) { int docid = mapper.getDocID(uid); if (docid != DocIDMapper.NOT_FOUND) { idSet.add(docid); } } } return idSet.toIntArray(); }
public static int[] mapUID(long[] uidArray,DocIDMapper<?> mapper) { IntRBTreeSet idSet = new IntRBTreeSet(); for (long uid : uidArray) { if (uid != ZoieIndexReader.DELETED_UID) { int docid = mapper.getDocID(uid); if (docid!=DocIDMapper.NOT_FOUND) { idSet.add(docid); } } } return idSet.toIntArray(); }
public void markDeletes(LongSet delDocs, LongSet deletedUIDs) { LongIterator iter = delDocs.iterator(); IntRBTreeSet delDocIdSet = _delDocIdSet; while (iter.hasNext()) { long uid = iter.nextLong(); if (ZoieSegmentReader.DELETED_UID != uid) { int docid = _docIDMapper.getDocID(uid); if (docid != DocIDMapper.NOT_FOUND) { delDocIdSet.add(docid); deletedUIDs.add(uid); } } } }
public void markDeletes(LongSet delDocs, LongSet deletedUIDs) { LongIterator iter = delDocs.iterator(); IntRBTreeSet delDocIdSet = _delDocIdSet; while (iter.hasNext()) { long uid = iter.nextLong(); if (ZoieSegmentReader.DELETED_UID != uid) { int docid = _docIDMapper.getDocID(uid); if (docid != DocIDMapper.NOT_FOUND) { delDocIdSet.add(docid); deletedUIDs.add(uid); } } } }
public static IntSet mostSalient(final File reference, final File corpus, int W, int topN, SourceType sourceType) throws IOException { final PrecomputedValues precomp1 = PrecomputedValues.precompute(reference, W, SourceType.SIMPLE); final PrecomputedValues precomp2 = PrecomputedValues.precompute(corpus, W, sourceType); final double[] salience = new double[W]; final IntRBTreeSet topNWords = new IntRBTreeSet(new IntComparator() { @Override public int compare(int i, int i1) { return salience[i] < salience[i1] ? -1 : (salience[i] > salience[i1] ? 1 : i - i1); } @Override public int compare(Integer o1, Integer o2) { return compare(o1.intValue(), o2.intValue()); } }); for (int w = 0; w < W; w++) { final double val = precomp1.mu.value(w); final Double val2 = precomp2.mu.value(w); if (val != 0.0 && val2 != 0.0) { salience[w] = val / val2; if (topNWords.size() < topN) { topNWords.add(w); } else if (salience[w] > salience[topNWords.firstInt()]) { topNWords.remove(topNWords.first()); topNWords.add(w); } } } return topNWords; }
@Override public void markDeletes(LongSet delDocs, LongSet deletedUIDs) { DocIDMapper<?> idMapper = getDocIDMaper(); LongIterator iter = delDocs.iterator(); IntRBTreeSet delDocIdSet = _delDocIdSet; while(iter.hasNext()) { long uid = iter.nextLong(); if (ZoieIndexReader.DELETED_UID != uid) { int docid = idMapper.getDocID(uid); if(docid != DocIDMapper.NOT_FOUND) { delDocIdSet.add(docid); deletedUIDs.add(uid); } } } }
default Selection startsWith(String string) { Selection results = new BitmapBackedSelection(); IntRBTreeSet sorted = new IntRBTreeSet(); DictionaryMap dictionaryMap = this.dictionaryMap(); for (Object2IntMap.Entry<String> entry : dictionaryMap.valueToKeyMap().object2IntEntrySet()) { String key = entry.getKey(); if (key.startsWith(string)) { sorted.add(entry.getIntValue()); } } int i = 0; for (int next : values()) { if (sorted.contains(next)) { results.add(i); } i++; } return results; }