/** * Get the collection of values of this vector. * * @return The collection of all values in this vector. */ public DoubleCollection values() { DoubleArrayList lst = new DoubleArrayList(size()); IntIterator iter = keys.activeIndexIterator(false); while (iter.hasNext()) { int idx = iter.nextInt(); lst.add(values[idx]); } return lst; }
/** * Fast iterator over entries (it can reuse entry objects). * * @param state The state of entries to iterate. * @return a fast iterator over all key/value pairs * @see it.unimi.dsi.fastutil.longs.Long2DoubleMap.FastEntrySet#fastIterator() * Long2DoubleMap.FastEntrySet.fastIterator() * @since 0.11 */ public Iterator<VectorEntry> fastIterator(VectorEntry.State state) { IntIterator iter; switch (state) { case SET: iter = keys.activeIndexIterator(isMutable()); break; case UNSET: { iter = keys.clone().invert().activeIndexIterator(false); break; } case EITHER: { iter = IntIterators.fromTo(0, keys.domainSize()); break; } default: // should be impossible throw new IllegalArgumentException("invalid entry state"); } return new FastIterImpl(iter, state); }