Refine search
/** * Creates a new array list and fills it with the elements returned by a type-specific iterator.. * * @param i a type-specific iterator whose returned elements will fill the array list. */ public IdentityArrayList(final ObjectIterator<? extends K> i) { this(); while (i.hasNext()) this.add(i.next()); }
private void saveCanonicalIds() { Int2ObjectOpenHashMap mappings = canonicalIdHolder.getAllMappings(); for (ObjectIterator<Int2ObjectMap.Entry<?>> i = mappings.int2ObjectEntrySet().fastIterator(); i .hasNext();) { Int2ObjectMap.Entry<?> entry = i.next(); writeCanonicalId(entry.getIntKey(), entry.getValue()); } }
@Override public Matrix assign(Matrix other, DoubleDoubleFunction function) { //TODO generalize to other kinds of functions if (Functions.PLUS.equals(function) && other instanceof SparseMatrix) { int rows = rowSize(); if (rows != other.rowSize()) { throw new CardinalityException(rows, other.rowSize()); } int columns = columnSize(); if (columns != other.columnSize()) { throw new CardinalityException(columns, other.columnSize()); } SparseMatrix otherSparse = (SparseMatrix) other; for(ObjectIterator<Entry<Vector>> fastIterator = otherSparse.rowVectors.int2ObjectEntrySet().fastIterator(); fastIterator.hasNext();) { final Entry<Vector> entry = fastIterator.next(); final int rowIndex = entry.getIntKey(); Vector row = rowVectors.get(rowIndex); if (row == null) { rowVectors.put(rowIndex, entry.getValue().clone()); } else { row.assign(entry.getValue(), Functions.PLUS); } } return this; } else { return super.assign(other, function); } }
public static <K> boolean all(final ObjectIterator<K> iterator, final java.util.function.Predicate<? super K> predicate) { Objects.requireNonNull(predicate); do { if (!iterator.hasNext()) return true; } while (predicate.test(iterator.next())); return false; } public static <K> int indexOf(final ObjectIterator<K> iterator,