/** * 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(ObjectProcedure procedure) { Object[] 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(ObjectProcedure procedure) { Object[] 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(ObjectProcedure procedure) { Object[] 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 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.ObjectProcedure 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>[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.ObjectProcedure 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.ObjectProcedure 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>[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.ObjectProcedure 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>[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.ObjectProcedure 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.ObjectProcedure 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; } /**
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);