/** * Adds all of the elements in <tt>array</tt> to the set. * * @param array an <code>array</code> of double primitives. * @return true if the set was modified by the add all operation. */ public boolean addAll(double[] array) { boolean changed = false; for (int i = array.length; i-- > 0;) { if (add(array[i])) { changed = true; } } return changed; }
/** * Creates a new <code>TDoubleHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>double</code> primitives */ public TDoubleHashSet(double[] array) { this(array.length); addAll(array); }
/** * Creates an iterator over the values of the set. * * @return an iterator with support for removals in the underlying set */ public Iterator iterator() { return new Iterator() { private final TDoubleIterator it = _set.iterator(); public Object next() { return wrap(it.next()); } public boolean hasNext() { return it.hasNext(); } public void remove() { it.remove(); } }; }
/** * Compares this set with another set for equality of their stored * entries. * * @param other an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean equals(Object other) { if (! (other instanceof TDoubleHashSet)) { return false; } final TDoubleHashSet that = (TDoubleHashSet)other; if (that.size() != this.size()) { return false; } return forEach(new TDoubleProcedure() { public final boolean execute(double value) { return that.contains(value); } }); }
while (categories.hasNext()) { short category = categories.next(); scores.put(category, new TDoubleHashSet()); short category = categories.next(); double score = docScores.get(category).score; scores.get(category).add(score); while (categories.hasNext()) { short category = categories.next(); TDoubleIterator scoreIterator = scores.get(category).iterator(); double maxDelta = Double.NEGATIVE_INFINITY; while (scoreIterator.hasNext()) {
if (_set.equals(other)) { return true; // comparing two trove sets } else if (other instanceof Set) { Set that = (Set)other; if (that.size() != _set.size()) { return false; // different sizes, no need to compare } else { // now we have to do it the hard way if (val instanceof Double) { double v = unwrap(val); if (_set.contains(v)) {
/** * Compare les X de cette evolution avec <code>_toCompare</code>. Si les x sont diffrents renvoie false et stocke * dans <code>_commonX</code> l'union des valeurs des x. * * @param _toCompare l'evolution a comparer * @param _commonX la liste a remplir avec l'union des x des 2 evolutions si differentes * @return true si identique */ public boolean isEvolutionWithSameX(final EvolutionReguliere _toCompare, final TDoubleHashSet _commonX) { if (_toCompare == null) { return false; } if (t_.equals(_toCompare.t_)) { return true; } if (_commonX != null) { _commonX.ensureCapacity(t_.size() + _toCompare.t_.size()); _commonX.addAll(t_.toNativeArray()); _commonX.addAll(_toCompare.t_.toNativeArray()); } return false; }
public final boolean execute(double value) { return that.contains(value); } });
/** * Empties the set. */ public void clear() { this._set.clear(); }
private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); // number of entries stream.writeInt(_size); SerializationProcedure writeProcedure = new SerializationProcedure(stream); if (! forEach(writeProcedure)) { throw writeProcedure.exception; } }
/** * Tests the set to determine if all of the elements in * <tt>array</tt> are present. * * @param array an <code>array</code> of double primitives. * @return true if all elements were present in the set. */ public boolean containsAll(double[] array) { for (int i = array.length; i-- > 0;) { if (! contains(array[i])) { return false; } } return true; }
/** * Inserts a value into the set. * * @param true if the set was modified by the insertion */ public boolean add(Object value) { return _set.add(unwrap(value)); }
/** * Creates a new <code>TDoubleHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>double</code> primitives * @param strategy used to compute hash codes and to compare keys. */ public TDoubleHashSet(double[] array, TDoubleHashingStrategy strategy) { this(array.length, strategy); addAll(array); }