/** * Applies a procedure to each element of the receiver, if any. * Starts at index 0, moving rightwards. * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ public boolean forEach(DoubleProcedure procedure) { // overridden for performance only. double[] theElements = elements; int theSize = size; for (int i=0; i<theSize;) if (! procedure.apply(theElements[i++])) return false; return true; } /**
/** * Applies a procedure to each element of the receiver, if any. * Starts at index 0, moving rightwards. * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ public boolean forEach(DoubleProcedure procedure) { // overridden for performance only. double[] theElements = elements; int theSize = size; for (int i=0; i<theSize;) if (! procedure.apply(theElements[i++])) return false; return true; } /**
/** * Applies a procedure to each key of the receiver, if any. * Note: Iterates over the keys in no particular order. * Subclasses can define a particular order, for example, "sorted by key". * All methods which <i>can</i> be expressed in terms of this method (most methods can) <i>must guarantee</i> to use the <i>same</i> order defined by this method, even if it is no particular order. * This is necessary so that, for example, methods <tt>keys</tt> and <tt>values</tt> will yield association pairs, not two uncorrelated lists. * * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all keys where iterated over, <tt>true</tt> otherwise. */ public boolean forEachKey(DoubleProcedure procedure) { for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) if (! procedure.apply(table[i])) return false; } return true; } /**
/** * Applies a procedure to each key of the receiver, if any. * Note: Iterates over the keys in no particular order. * Subclasses can define a particular order, for example, "sorted by key". * All methods which <i>can</i> be expressed in terms of this method (most methods can) <i>must guarantee</i> to use the <i>same</i> order defined by this method, even if it is no particular order. * This is necessary so that, for example, methods <tt>keys</tt> and <tt>values</tt> will yield association pairs, not two uncorrelated lists. * * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all keys where iterated over, <tt>true</tt> otherwise. */ public boolean forEachKey(DoubleProcedure procedure) { for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) if (! procedure.apply(table[i])) return false; } return true; } /**
/** * Applies a procedure to each element of the receiver, if any. Starts at * index 0, moving rightwards. * * @param procedure * the procedure to be applied. Stops iteration if the procedure * returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where * iterated over, <tt>true</tt> otherwise. */ public boolean forEach(DoubleProcedure procedure) { // overridden for performance only. double[] theElements = elements; int theSize = size; for (int i = 0; i < theSize;) if (!procedure.apply(theElements[i++])) return false; return true; }
/** * Applies a procedure to each key of the receiver, if any. Note: Iterates * over the keys in no particular order. Subclasses can define a particular * order, for example, "sorted by key". All methods which <i>can</i> be * expressed in terms of this method (most methods can) <i>must * guarantee</i> to use the <i>same</i> order defined by this method, even * if it is no particular order. This is necessary so that, for example, * methods <tt>keys</tt> and <tt>values</tt> will yield association pairs, * not two uncorrelated lists. * * @param procedure * the procedure to be applied. Stops iteration if the procedure * returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all keys where * iterated over, <tt>true</tt> otherwise. */ public boolean forEachKey(DoubleProcedure procedure) { for (int i = table.length; i-- > 0;) { if (state[i] == FULL) if (!procedure.apply(table[i])) return false; } return true; }
/** * Applies a procedure to each element of the receiver, if any. * Starts at index 0, moving rightwards. * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ public boolean forEach(DoubleProcedure procedure) { for (int i=0; i<size;) if (! procedure.apply(get(i++))) return false; return true; } /**
/** * Applies a procedure to each element of the receiver, if any. * Starts at index 0, moving rightwards. * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ public boolean forEach(DoubleProcedure procedure) { for (int i=0; i<size;) if (! procedure.apply(get(i++))) return false; return true; } /**
/** * Applies a procedure to each element of the receiver, if any. Starts at * index 0, moving rightwards. * * @param procedure * the procedure to be applied. Stops iteration if the procedure * returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where * iterated over, <tt>true</tt> otherwise. */ public boolean forEach(DoubleProcedure procedure) { for (int i = 0; i < size;) if (!procedure.apply(get(i++))) return false; return true; }
/** * Applies a procedure to each cell's value. * Iterates downwards from <tt>[size()-1]</tt> to <tt>[0]</tt>, * as demonstrated by this snippet: * <pre> * for (int i=size(); --i >=0;) { * if (!procedure.apply(getQuick(i))) return false; * } * return true; * </pre> * Note that an implementation may use more efficient techniques, but must not use any other order. * * @param procedure a procedure object taking as argument the current cell's value. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ private boolean xforEach(final cern.colt.function.DoubleProcedure procedure) { for (int i=size; --i >= 0;) { if (!procedure.apply(getQuick(i))) return false; } return true; } /**
/** * Applies a procedure to each cell's value. * Iterates downwards from <tt>[size()-1]</tt> to <tt>[0]</tt>, * as demonstrated by this snippet: * <pre> * for (int i=size(); --i >=0;) { * if (!procedure.apply(getQuick(i))) return false; * } * return true; * </pre> * Note that an implementation may use more efficient techniques, but must not use any other order. * * @param procedure a procedure object taking as argument the current cell's value. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ private boolean xforEach(final cern.colt.function.DoubleProcedure procedure) { for (int i=size; --i >= 0;) { if (!procedure.apply(getQuick(i))) return false; } return true; } /**
/** * Applies a procedure to each cell's value. * Iterates downwards from <tt>[rows()-1,columns()-1]</tt> to <tt>[0,0]</tt>, * as demonstrated by this snippet: * <pre> * for (int row=rows; --row >=0;) { * for (int column=columns; --column >= 0;) { * if (!procedure.apply(getQuick(row,column))) return false; * } * } * return true; * </pre> * Note that an implementation may use more efficient techniques, but must not use any other order. * * @param procedure a procedure object taking as argument the current cell's value. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ private boolean xforEach(final cern.colt.function.DoubleProcedure procedure) { for (int row=rows; --row >= 0;) { for (int column=columns; --column >= 0;) { if (!procedure.apply(getQuick(row,column))) return false; } } return true; } /**
/** * Applies a procedure to each cell's value. * Iterates downwards from <tt>[rows()-1,columns()-1]</tt> to <tt>[0,0]</tt>, * as demonstrated by this snippet: * <pre> * for (int row=rows; --row >=0;) { * for (int column=columns; --column >= 0;) { * if (!procedure.apply(getQuick(row,column))) return false; * } * } * return true; * </pre> * Note that an implementation may use more efficient techniques, but must not use any other order. * * @param procedure a procedure object taking as argument the current cell's value. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ private boolean xforEach(final cern.colt.function.DoubleProcedure procedure) { for (int row=rows; --row >= 0;) { for (int column=columns; --column >= 0;) { if (!procedure.apply(getQuick(row,column))) return false; } } return true; } /**
/** * Applies a procedure to each cell's value. * Iterates downwards from <tt>[slices()-1,rows()-1,columns()-1]</tt> to <tt>[0,0,0]</tt>, * as demonstrated by this snippet: * <pre> * for (int slice=slices; --slice >=0;) { * for (int row=rows; --row >= 0;) { * for (int column=columns; --column >= 0;) { * if (!procedure.apply(get(slice,row,column))) return false; * } * } * } * return true; * </pre> * Note that an implementation may use more efficient techniques, but must not use any other order. * * @param procedure a procedure object taking as argument the current cell's value. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ private boolean xforEach(final cern.colt.function.DoubleProcedure procedure) { for (int slice=slices; --slice >= 0;) { for (int row=rows; --row >= 0;) { for (int column=columns; --column >= 0;) { if (!procedure.apply(getQuick(slice,row,column))) return false; } } } return true; } /**
/** * Applies a procedure to each cell's value. * Iterates downwards from <tt>[slices()-1,rows()-1,columns()-1]</tt> to <tt>[0,0,0]</tt>, * as demonstrated by this snippet: * <pre> * for (int slice=slices; --slice >=0;) { * for (int row=rows; --row >= 0;) { * for (int column=columns; --column >= 0;) { * if (!procedure.apply(get(slice,row,column))) return false; * } * } * } * return true; * </pre> * Note that an implementation may use more efficient techniques, but must not use any other order. * * @param procedure a procedure object taking as argument the current cell's value. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ private boolean xforEach(final cern.colt.function.DoubleProcedure procedure) { for (int slice=slices; --slice >= 0;) { for (int row=rows; --row >= 0;) { for (int column=columns; --column >= 0;) { if (!procedure.apply(getQuick(slice,row,column))) return false; } } } return true; } /**
/** * Applies a procedure to each element of the receiver, if any. * Iterates over the receiver in no particular order. * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ public boolean forEach(cern.colt.function.DoubleProcedure procedure) { double[] theElements = buffer.elements(); int theSize = (int) size(); for (int i=0; i<theSize;) if (! procedure.apply(theElements[i++])) return false; return true; } /**
/** * Applies a procedure to each element of the receiver, if any. * Iterates over the receiver in no particular order. * @param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues. * @return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. */ public boolean forEach(cern.colt.function.DoubleProcedure procedure) { double[] theElements = buffer.elements(); int theSize = (int) size(); for (int i=0; i<theSize;) if (! procedure.apply(theElements[i++])) return false; return true; } /**
IntArrayList matches = new IntArrayList(); for (int i=0; i < size; i++) { if (condition.apply(getQuick(i))) matches.add(i);
IntArrayList matches = new IntArrayList(); for (int i=0; i < size; i++) { if (condition.apply(getQuick(i))) matches.add(i);