/* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ package com.l2jserver.util; import java.util.Collection; import javolution.util.FastList; import com.l2jserver.gameserver.model.IL2Procedure; /** * A custom version of FastList with extension for iterating without using temporary collection
* It's provide synchronization lock when iterating if needed
*
* @author Julian * @version 1.0.1 (2008-02-07)
* 1.0.0 - Initial version.
* 1.0.1 - Made forEachP() final.
* @author UnAfraid * @version 1.0.2 (20012-08-19)
* 1.0.2 - Using IL2Procedure instead of IForEach. * @param */ public class L2FastList extends FastList { private static final long serialVersionUID = 8354641653178203420L; public L2FastList() { this(false); } public L2FastList(int initialCapacity) { this(initialCapacity, false); } public L2FastList(Collection c) { this(c, false); } public L2FastList(boolean shared) { super(); if (shared) { shared(); } } public L2FastList(int initialCapacity, boolean shared) { super(initialCapacity); if (shared) { shared(); } } public L2FastList(Collection c, boolean shared) { super(c); if (shared) { shared(); } } /** * Public method that iterate entire collection.
*
* @param proc - a class method that must be executed on every element of collection.
* @return - returns true if entire collection is iterated, false if it`s been interrupted by
* check method (IL2Procedure.execute(T))
*/ public boolean executeForEach(IL2Procedure proc) { for (T e : this) { if (!proc.execute(e)) { return false; } } return true; } }