Browse Source

BETA: Updating L2FastList/L2FastMap to use IL2Procedure and drop of all unused custom maps in gameserver's util package.

Rumen Nikiforov 12 years ago
parent
commit
a6ca1b9bbc

+ 0 - 406
L2J_Server_BETA/java/com/l2jserver/gameserver/util/L2ObjectHashMap.java

@@ -1,406 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import com.l2jserver.gameserver.model.L2Object;
-
-/**
- * This class is a highly optimized hash table, where keys are integers.<br>
- * The main goal of this class is to allow concurrent read/iterate and write access to this table, plus minimal used memory.<br>
- * This class uses plain array as the table of values, and keys are used to get position in the table.<br>
- * If the position is already busy, we iterate to the next position, until we find the needed element or null.<br>
- * To iterate over the table (read access) we may simply iterate through table array.<br>
- * In case we remove an element from the table, we check - if the next position is null, we reset table's slot to null, otherwise we assign it to a dummy value.
- * @param <T> type of values stored in this hash table.
- * @author mkizub
- */
-public final class L2ObjectHashMap<T extends L2Object> extends L2ObjectMap<T>
-{
-	private static final boolean TRACE = false;
-	private static final boolean DEBUG = false;
-	
-	private static final int[] PRIMES = {
-		5, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293,
-		353, 431, 521, 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801,
-		3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591, 17519,
-		21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523,
-		108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357,
-		467237, 560689, 672827, 807403, 968897, 1162687, 1395263, 1674319,
-		2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369
-	};
-	
-	private T[] _table;
-	private int[] _keys;
-	private int _count;
-	
-	private static int getPrime(int min)
-	{
-		for (int element : PRIMES)
-		{
-			if (element >= min)
-			{
-				return element;
-			}
-		}
-		throw new OutOfMemoryError();
-	}
-	
-	@SuppressWarnings("unchecked")
-	public L2ObjectHashMap()
-	{
-		int size = PRIMES[0];
-		_table = (T[])new L2Object[size];
-		_keys = new int[size];
-		if (DEBUG)
-		{
-			check();
-		}
-	}
-	
-	@Override
-	public int size()
-	{
-		return _count;
-	}
-	
-	@Override
-	public boolean isEmpty()
-	{
-		return _count == 0;
-	}
-	
-	@Override
-	@SuppressWarnings("unchecked")
-	public synchronized void clear()
-	{
-		int size = PRIMES[0];
-		_table = (T[])new L2Object[size];
-		_keys = new int[size];
-		_count = 0;
-		if (DEBUG)
-		{
-			check();
-		}
-	}
-	
-	private void check()
-	{
-		if (DEBUG)
-		{
-			int cnt = 0;
-			for (int i=0; i < _table.length; i++)
-			{
-				L2Object obj = _table[i];
-				if (obj == null) {
-					assert (_keys[i] == 0) || (_keys[i] == 0x80000000);
-				} else {
-					cnt++;
-					assert obj.getObjectId() == (_keys[i] & 0x7FFFFFFF);
-				}
-			}
-			assert cnt == _count;
-		}
-	}
-	
-	@Override
-	public synchronized void put(T obj)
-	{
-		if (_count >= (_table.length/2))
-		{
-			expand();
-		}
-		final int hashcode = obj.getObjectId();
-		assert hashcode > 0;
-		int seed = hashcode;
-		int incr = 1 + (((seed >> 5) + 1) % (_table.length - 1));
-		int ntry = 0;
-		int slot = -1; // keep last found slot
-		do
-		{
-			int pos = (seed % _table.length) & 0x7FFFFFFF;
-			if (_table[pos] == null)
-			{
-				if (slot < 0)
-				{
-					slot = pos;
-				}
-				if (_keys[pos] >= 0) {
-					// found an empty slot without previous collisions,
-					// but use previously found slot
-					_keys[slot] = hashcode;
-					_table[slot] = obj;
-					_count++;
-					if (TRACE)
-					{
-						System.err.println("ht: put obj id="+hashcode+" at slot="+slot);
-					}
-					if (DEBUG)
-					{
-						check();
-					}
-					return;
-				}
-			}
-			else
-			{
-				// check if we are adding the same object
-				if (_table[pos] == obj)
-				{
-					return;
-				}
-				// this should never happen
-				assert obj.getObjectId() != _table[pos].getObjectId();
-				// if there was no collisions at this slot, and we found a free
-				// slot previously - use found slot
-				if ((slot >= 0) && (_keys[pos] > 0))
-				{
-					_keys[slot] |= hashcode; // preserve collision bit
-					_table[slot] = obj;
-					_count++;
-					if (TRACE)
-					{
-						System.err.println("ht: put obj id="+hashcode+" at slot="+slot);
-					}
-					if (DEBUG)
-					{
-						check();
-					}
-					return;
-				}
-			}
-			
-			// set collision bit
-			_keys[pos] |= 0x80000000;
-			// calculate next slot
-			seed += incr;
-		} while (++ntry < _table.length);
-		if (DEBUG)
-		{
-			check();
-		}
-		throw new IllegalStateException();
-	}
-	
-	@Override
-	public synchronized void remove(T obj)
-	{
-		int hashcode = obj.getObjectId();
-		assert hashcode > 0;
-		int seed = hashcode;
-		int incr = 1 + (((seed >> 5) + 1) % (_table.length - 1));
-		int ntry = 0;
-		do
-		{
-			int pos = (seed % _table.length) & 0x7FFFFFFF;
-			if (_table[pos] == obj)
-			{
-				// found the object
-				_keys[pos] &= 0x80000000; // preserve collision bit
-				_table[pos] = null;
-				_count--;
-				if (TRACE)
-				{
-					System.err.println("ht: remove obj id="+hashcode+" from slot="+pos);
-				}
-				if (DEBUG)
-				{
-					check();
-				}
-				return;
-			}
-			// check for collision (if we previously deleted element)
-			if ((_table[pos] == null) && (_keys[pos] >= 0)) {
-				if (DEBUG)
-				{
-					check();
-				}
-				return; //throw new IllegalArgumentException();
-			}
-			// calculate next slot
-			seed += incr;
-		} while (++ntry < _table.length);
-		if (DEBUG)
-		{
-			check();
-		}
-		throw new IllegalStateException();
-	}
-	
-	@Override
-	public T get(int id)
-	{
-		final int size = _table.length;
-		if (id <= 0)
-		{
-			return null;
-		}
-		if (size <= 11)
-		{
-			// for small tables linear check is fast
-			for (int i=0; i < size; i++)
-			{
-				if ((_keys[i]&0x7FFFFFFF) == id)
-				{
-					return _table[i];
-				}
-			}
-			return null;
-		}
-		int seed = id;
-		int incr = 1 + (((seed >> 5) + 1) % (size - 1));
-		int ntry = 0;
-		do
-		{
-			int pos = (seed % size) & 0x7FFFFFFF;
-			if ((_keys[pos]&0x7FFFFFFF) == id)
-			{
-				return _table[pos];
-			}
-			// check for collision (if we previously deleted element)
-			if ((_table[pos] == null) && (_keys[pos] >= 0)) {
-				return null;
-			}
-			// calculate next slot
-			seed += incr;
-		} while (++ntry < size);
-		return null;
-	}
-	
-	@Override
-	public boolean contains(T obj)
-	{
-		return get(obj.getObjectId()) != null;
-	}
-	
-	@SuppressWarnings("unchecked")
-	private /*already synchronized in put()*/ void expand()
-	{
-		int newSize = getPrime(_table.length+1);
-		L2Object[] newTable = new L2Object[newSize];
-		int[] newKeys = new int[newSize];
-		
-		// over all old entries
-		next_entry:
-			for (int i=0; i < _table.length; i++)
-			{
-				L2Object obj = _table[i];
-				if (obj == null)
-				{
-					continue;
-				}
-				final int hashcode = _keys[i] & 0x7FFFFFFF;
-				assert hashcode == obj.getObjectId();
-				int seed = hashcode;
-				int incr = 1 + (((seed >> 5) + 1) % (newSize - 1));
-				int ntry = 0;
-				do
-				{
-					int pos = (seed % newSize) & 0x7FFFFFFF;
-					if (newTable[pos] == null)
-					{
-						assert (newKeys[pos] == 0) && (hashcode != 0);
-						// found an empty slot without previous collisions,
-						// but use previously found slot
-						newKeys[pos] = hashcode;
-						newTable[pos] = obj;
-						if (TRACE)
-						{
-							System.err.println("ht: move obj id="+hashcode+" from slot="+i+" to slot="+pos);
-						}
-						continue next_entry;
-					}
-					// set collision bit
-					newKeys[pos] |= 0x80000000;
-					// calculate next slot
-					seed += incr;
-				} while (++ntry < newSize);
-				throw new IllegalStateException();
-			}
-		_table = (T[])newTable;
-		_keys = newKeys;
-		if (DEBUG)
-		{
-			check();
-		}
-	}
-	
-	@Override
-	public Iterator<T> iterator()
-	{
-		return new Itr(_table);
-	}
-	
-	class Itr implements Iterator<T>
-	{
-		private final T[] _array;
-		private int _nextIdx;
-		private T _nextObj;
-		private T _lastRet;
-		
-		Itr(T[] pArray)
-		{
-			this._array = pArray;
-			for (; _nextIdx < _array.length; _nextIdx++)
-			{
-				_nextObj = _array[_nextIdx];
-				if (_nextObj != null)
-				{
-					return;
-				}
-			}
-		}
-		
-		@Override
-		public boolean hasNext()
-		{
-			return _nextObj != null;
-		}
-		
-		@Override
-		public T next()
-		{
-			if (_nextObj == null)
-			{
-				throw new NoSuchElementException();
-			}
-			_lastRet = _nextObj;
-			for (_nextIdx++; _nextIdx < _array.length; _nextIdx++)
-			{
-				_nextObj = _array[_nextIdx];
-				if (_nextObj != null)
-				{
-					break;
-				}
-			}
-			if (_nextIdx >= _array.length)
-			{
-				_nextObj = null;
-			}
-			return _lastRet;
-		}
-		@Override
-		public void remove()
-		{
-			if (_lastRet == null)
-			{
-				throw new IllegalStateException();
-			}
-			L2ObjectHashMap.this.remove(_lastRet);
-		}
-	}
-}

+ 0 - 480
L2J_Server_BETA/java/com/l2jserver/gameserver/util/L2ObjectHashSet.java

@@ -1,480 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import com.l2jserver.gameserver.model.L2Object;
-
-/**
- * This class is a highly optimized hash table, where keys are integers.<br>
- * The main goal of this class is to allow concurrent read/iterate and write access to this table, plus minimal used memory.<br>
- * This class uses plain array as the table of values, and keys are used to get position in the table.<br>
- * If the position is already busy, we iterate to the next position, until we find the needed element or null.<br>
- * To iterate over the table (read access) we may simply iterate through table array.<br>
- * In case we remove an element from the table, we check - if the next position is null, we reset table's slot to null, otherwise we assign it to a dummy value.
- * @author mkizub
- * @param <T> type of values stored in this hash table.
- */
-public final class L2ObjectHashSet<T extends L2Object> extends L2ObjectSet<T>
-{
-	private static final boolean TRACE = false;
-	private static final boolean DEBUG = false;
-	
-	private static final int[] PRIMES =
-	{
-		5,
-		7,
-		11,
-		17,
-		23,
-		29,
-		37,
-		47,
-		59,
-		71,
-		89,
-		107,
-		131,
-		163,
-		197,
-		239,
-		293,
-		353,
-		431,
-		521,
-		631,
-		761,
-		919,
-		1103,
-		1327,
-		1597,
-		1931,
-		2333,
-		2801,
-		3371,
-		4049,
-		4861,
-		5839,
-		7013,
-		8419,
-		10103,
-		12143,
-		14591,
-		17519,
-		21023,
-		25229,
-		30293,
-		36353,
-		43627,
-		52361,
-		62851,
-		75431,
-		90523,
-		108631,
-		130363,
-		156437,
-		187751,
-		225307,
-		270371,
-		324449,
-		389357,
-		467237,
-		560689,
-		672827,
-		807403,
-		968897,
-		1162687,
-		1395263,
-		1674319,
-		2009191,
-		2411033,
-		2893249,
-		3471899,
-		4166287,
-		4999559,
-		5999471,
-		7199369
-	};
-	
-	private T[] _table;
-	private int[] _collisions;
-	private int _count;
-	
-	private static int getPrime(int min)
-	{
-		for (int element : PRIMES)
-		{
-			if (element >= min)
-			{
-				return element;
-			}
-		}
-		throw new OutOfMemoryError();
-	}
-	
-	@SuppressWarnings("unchecked")
-	public L2ObjectHashSet()
-	{
-		int size = PRIMES[0];
-		_table = (T[]) new L2Object[size];
-		_collisions = new int[(size + 31) >> 5];
-		if (DEBUG)
-		{
-			check();
-		}
-	}
-	
-	@Override
-	public int size()
-	{
-		return _count;
-	}
-	
-	@Override
-	public boolean isEmpty()
-	{
-		return _count == 0;
-	}
-	
-	@Override
-	@SuppressWarnings("unchecked")
-	public synchronized void clear()
-	{
-		int size = PRIMES[0];
-		_table = (T[]) new L2Object[size];
-		_collisions = new int[(size + 31) >> 5];
-		_count = 0;
-		if (DEBUG)
-		{
-			check();
-		}
-	}
-	
-	private void check()
-	{
-		if (DEBUG)
-		{
-			int cnt = 0;
-			assert _collisions.length == ((_table.length + 31) >> 5);
-			for (T obj : _table)
-			{
-				if (obj != null)
-				{
-					cnt++;
-				}
-			}
-			assert cnt == _count;
-		}
-	}
-	
-	@Override
-	public synchronized void put(T obj)
-	{
-		if (obj == null)
-		{
-			return;
-		}
-		if (contains(obj))
-		{
-			return;
-		}
-		if (_count >= (_table.length / 2))
-		{
-			expand();
-		}
-		final int hashcode = obj.getObjectId();
-		assert hashcode > 0;
-		int seed = hashcode;
-		int incr = 1 + (((seed >> 5) + 1) % (_table.length - 1));
-		int ntry = 0;
-		int slot = -1; // keep last found slot
-		do
-		{
-			int pos = (seed % _table.length) & 0x7FFFFFFF;
-			if (_table[pos] == null)
-			{
-				if (slot < 0)
-				{
-					slot = pos;
-				}
-				if ((_collisions[pos >> 5] & (1 << (pos & 31))) == 0)
-				{
-					// found an empty slot without previous collisions,
-					// but use previously found slot
-					_table[slot] = obj;
-					_count++;
-					if (TRACE)
-					{
-						System.err.println("ht: put obj id=" + hashcode + " at slot=" + slot);
-					}
-					if (DEBUG)
-					{
-						check();
-					}
-					return;
-				}
-			}
-			else
-			{
-				// check if we are adding the same object
-				if (_table[pos] == obj)
-				{
-					return;
-				}
-				// this should never happen
-				assert obj.getObjectId() != _table[pos].getObjectId();
-				// if there was no collisions at this slot, and we found a free
-				// slot previously - use found slot
-				if ((slot >= 0) && ((_collisions[pos >> 5] & (1 << (pos & 31))) == 0))
-				{
-					_table[slot] = obj;
-					_count++;
-					if (TRACE)
-					{
-						System.err.println("ht: put obj id=" + hashcode + " at slot=" + slot);
-					}
-					if (DEBUG)
-					{
-						check();
-					}
-					return;
-				}
-			}
-			
-			// set collision bit
-			_collisions[pos >> 5] |= 1 << (pos & 31);
-			// calculate next slot
-			seed += incr;
-		}
-		while (++ntry < _table.length);
-		if (DEBUG)
-		{
-			check();
-		}
-		throw new IllegalStateException();
-	}
-	
-	@Override
-	public synchronized void remove(T obj)
-	{
-		if (obj == null)
-		{
-			return;
-		}
-		if (!contains(obj))
-		{
-			return;
-		}
-		int hashcode = obj.getObjectId();
-		assert hashcode > 0;
-		int seed = hashcode;
-		int incr = 1 + (((seed >> 5) + 1) % (_table.length - 1));
-		int ntry = 0;
-		do
-		{
-			int pos = (seed % _table.length) & 0x7FFFFFFF;
-			if (_table[pos] == obj)
-			{
-				// found the object
-				_table[pos] = null;
-				_count--;
-				if (TRACE)
-				{
-					System.err.println("ht: remove obj id=" + hashcode + " from slot=" + pos);
-				}
-				if (DEBUG)
-				{
-					check();
-				}
-				return;
-			}
-			// check for collision (if we previously deleted element)
-			if ((_table[pos] == null) && ((_collisions[pos >> 5] & (1 << (pos & 31))) == 0))
-			{
-				if (DEBUG)
-				{
-					check();
-				}
-				return; // throw new IllegalArgumentException();
-			}
-			// calculate next slot
-			seed += incr;
-		}
-		while (++ntry < _table.length);
-		if (DEBUG)
-		{
-			check();
-		}
-		throw new IllegalStateException();
-	}
-	
-	@Override
-	public boolean contains(T obj)
-	{
-		final int size = _table.length;
-		if (size <= 11)
-		{
-			// for small tables linear check is fast
-			for (int i = 0; i < size; i++)
-			{
-				if (_table[i] == obj)
-				{
-					return true;
-				}
-			}
-			return false;
-		}
-		int hashcode = obj.getObjectId();
-		assert hashcode > 0;
-		int seed = hashcode;
-		int incr = 1 + (((seed >> 5) + 1) % (size - 1));
-		int ntry = 0;
-		do
-		{
-			int pos = (seed % size) & 0x7FFFFFFF;
-			if (_table[pos] == obj)
-			{
-				return true;
-			}
-			// check for collision (if we previously deleted element)
-			if ((_table[pos] == null) && ((_collisions[pos >> 5] & (1 << (pos & 31))) == 0))
-			{
-				return false;
-			}
-			// calculate next slot
-			seed += incr;
-		}
-		while (++ntry < size);
-		return false;
-	}
-	
-	@SuppressWarnings("unchecked")
-	private/* already synchronized in put() */void expand()
-	{
-		int newSize = getPrime(_table.length + 1);
-		L2Object[] newTable = new L2Object[newSize];
-		int[] newCollisions = new int[(newSize + 31) >> 5];
-		
-		// over all old entries
-		next_entry:
-		for (int i = 0; i < _table.length; i++)
-		{
-			L2Object obj = _table[i];
-			if (obj == null)
-			{
-				continue;
-			}
-			final int hashcode = obj.getObjectId();
-			int seed = hashcode;
-			int incr = 1 + (((seed >> 5) + 1) % (newSize - 1));
-			int ntry = 0;
-			do
-			{
-				int pos = (seed % newSize) & 0x7FFFFFFF;
-				if (newTable[pos] == null)
-				{
-					// found an empty slot without previous collisions,
-					// but use previously found slot
-					newTable[pos] = obj;
-					if (TRACE)
-					{
-						System.err.println("ht: move obj id=" + hashcode + " from slot=" + i + " to slot=" + pos);
-					}
-					continue next_entry;
-				}
-				// set collision bit
-				newCollisions[pos >> 5] |= 1 << (pos & 31);
-				// calculate next slot
-				seed += incr;
-			}
-			while (++ntry < newSize);
-			throw new IllegalStateException();
-		}
-		_table = (T[]) newTable;
-		_collisions = newCollisions;
-		if (DEBUG)
-		{
-			check();
-		}
-	}
-	
-	@Override
-	public Iterator<T> iterator()
-	{
-		return new Itr(_table);
-	}
-	
-	class Itr implements Iterator<T>
-	{
-		private final T[] _array;
-		private int _nextIdx;
-		private T _nextObj;
-		private T _lastRet;
-		
-		Itr(T[] pArray)
-		{
-			this._array = pArray;
-			for (; _nextIdx < _array.length; _nextIdx++)
-			{
-				_nextObj = _array[_nextIdx];
-				if (_nextObj != null)
-				{
-					return;
-				}
-			}
-		}
-		
-		@Override
-		public boolean hasNext()
-		{
-			return _nextObj != null;
-		}
-		
-		@Override
-		public T next()
-		{
-			if (_nextObj == null)
-			{
-				throw new NoSuchElementException();
-			}
-			_lastRet = _nextObj;
-			for (_nextIdx++; _nextIdx < _array.length; _nextIdx++)
-			{
-				_nextObj = _array[_nextIdx];
-				if (_nextObj != null)
-				{
-					break;
-				}
-			}
-			if (_nextIdx >= _array.length)
-			{
-				_nextObj = null;
-			}
-			return _lastRet;
-		}
-		
-		@Override
-		public void remove()
-		{
-			if (_lastRet == null)
-			{
-				throw new IllegalStateException();
-			}
-			L2ObjectHashSet.this.remove(_lastRet);
-		}
-	}
-}

+ 0 - 56
L2J_Server_BETA/java/com/l2jserver/gameserver/util/L2ObjectMap.java

@@ -1,56 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Iterator;
-
-import com.l2jserver.Config;
-import com.l2jserver.gameserver.model.L2Object;
-
-/**
- * This class ...
- * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
- * @param <T>
- */
-public abstract class L2ObjectMap<T extends L2Object> implements Iterable<T>
-{
-	public abstract int size();
-	
-	public abstract boolean isEmpty();
-	
-	public abstract void clear();
-	
-	public abstract void put(T obj);
-	
-	public abstract void remove(T obj);
-	
-	public abstract T get(int id);
-	
-	public abstract boolean contains(T obj);
-	
-	@Override
-	public abstract Iterator<T> iterator();
-	
-	public static L2ObjectMap<L2Object> createL2ObjectMap()
-	{
-		switch (Config.MAP_TYPE)
-		{
-			case WorldObjectMap:
-				return new WorldObjectMap<>();
-			default:
-				return new WorldObjectTree<>();
-		}
-	}
-}

+ 0 - 66
L2J_Server_BETA/java/com/l2jserver/gameserver/util/L2ObjectSet.java

@@ -1,66 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Iterator;
-
-import com.l2jserver.Config;
-import com.l2jserver.gameserver.model.L2Object;
-import com.l2jserver.gameserver.model.actor.L2Playable;
-
-/**
- * This class ...
- * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
- * @param <T>
- */
-public abstract class L2ObjectSet<T extends L2Object> implements Iterable<T>
-{
-	public static L2ObjectSet<L2Object> createL2ObjectSet()
-	{
-		switch (Config.SET_TYPE)
-		{
-			case WorldObjectSet:
-				return new WorldObjectSet<>();
-			default:
-				return new L2ObjectHashSet<>();
-		}
-	}
-	
-	public static L2ObjectSet<L2Playable> createL2PlayerSet()
-	{
-		switch (Config.SET_TYPE)
-		{
-			case WorldObjectSet:
-				return new WorldObjectSet<>();
-			default:
-				return new L2ObjectHashSet<>();
-		}
-	}
-	
-	public abstract int size();
-	
-	public abstract boolean isEmpty();
-	
-	public abstract void clear();
-	
-	public abstract void put(T obj);
-	
-	public abstract void remove(T obj);
-	
-	public abstract boolean contains(T obj);
-	
-	@Override
-	public abstract Iterator<T> iterator();
-}

+ 0 - 439
L2J_Server_BETA/java/com/l2jserver/gameserver/util/L2SyncList.java

@@ -1,439 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
-
-/**
- * Highly concurrent List wrapping class, thread-safe.<br>
- * The default constructor sets a wrapped class to ArrayList<T> to minimize code line when wrapped class type is not that important.<br>
- * Note: Iterator returned does not support element removal!
- * @author Julian
- * @param <T>
- */
-public class L2SyncList<T extends Object> implements List<T>
-{
-	private final List<T> _list;
-	private final ReentrantReadWriteLock _rw = new ReentrantReadWriteLock();
-	private final ReadLock _rl = _rw.readLock();
-	private final WriteLock _wl = _rw.writeLock();
-	
-	/**
-	 * Default constructor use ArrayList as it internal
-	 */
-	public L2SyncList()
-	{
-		_list = new ArrayList<>();
-	}
-	
-	public L2SyncList(List<T> list)
-	{
-		_list = list;
-	}
-	
-	@Override
-	public T get(int index)
-	{
-		_rl.lock();
-		try
-		{
-			return _list.get(index);
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean equals(Object o)
-	{
-		_rl.lock();
-		try
-		{
-			return _list.equals(o);
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public int hashCode()
-	{
-		_rl.lock();
-		try
-		{
-			return _list.hashCode();
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public T set(int index, T element)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.set(index, element);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public void add(int index, T element)
-	{
-		_wl.lock();
-		try
-		{
-			_list.add(index, element);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean add(T element)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.add(element);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public T remove(int index)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.remove(index);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean remove(Object value)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.remove(value);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean removeAll(Collection<?> list)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.removeAll(list);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean retainAll(Collection<?> list)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.retainAll(list);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public int indexOf(Object o)
-	{
-		_rl.lock();
-		try
-		{
-			return _list.indexOf(o);
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean contains(Object o)
-	{
-		_rl.lock();
-		try
-		{
-			return _list.contains(o);
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean containsAll(Collection<?> list)
-	{
-		_rl.lock();
-		try
-		{
-			return _list.containsAll(list);
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public int lastIndexOf(Object o)
-	{
-		_rl.lock();
-		try
-		{
-			return _list.lastIndexOf(o);
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean addAll(Collection<? extends T> list)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.addAll(list);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean addAll(int index, Collection<? extends T> c)
-	{
-		_wl.lock();
-		try
-		{
-			return _list.addAll(index, c);
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public List<T> subList(int fromIndex, int toIndex)
-	{
-		_rl.lock();
-		try
-		{
-			return new L2SyncList<>(_list.subList(fromIndex, toIndex));
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public void clear()
-	{
-		_wl.lock();
-		try
-		{
-			_list.clear();
-		}
-		finally
-		{
-			_wl.unlock();
-		}
-	}
-	
-	@Override
-	public int size()
-	{
-		_rl.lock();
-		try
-		{
-			return _list.size();
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	public boolean isEmpty()
-	{
-		_rl.lock();
-		try
-		{
-			return _list.isEmpty();
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	/**
-	 * <FONT color="#FF0000">WARNING: Unsupported</FONT>
-	 * @return
-	 */
-	@Override
-	public ListIterator<T> listIterator()
-	{
-		throw new UnsupportedOperationException();
-	}
-	
-	/**
-	 * <FONT color="#FF0000">WARNING: Unsupported</FONT>
-	 * @see java.util.List#listIterator(int)
-	 */
-	@Override
-	public ListIterator<T> listIterator(int index)
-	{
-		throw new UnsupportedOperationException();
-	}
-	
-	/**
-	 * <FONT color="#FF0000">WARNING: Returned iterator use cloned List</FONT>
-	 * @see java.util.List#iterator()
-	 */
-	@Override
-	@SuppressWarnings("unchecked")
-	public Iterator<T> iterator()
-	{
-		return new Itr((T[]) _list.toArray());
-	}
-	
-	private class Itr implements Iterator<T>
-	{
-		int cursor; // index of next element to return
-		int lastRet = -1; // index of last element returned; -1 if no such
-		int size;
-		T[] elementData;
-		
-		public Itr(T[] data)
-		{
-			elementData = data;
-			if (data != null)
-			{
-				size = data.length;
-			}
-			else
-			{
-				size = 0;
-			}
-		}
-		
-		@Override
-		public boolean hasNext()
-		{
-			return cursor != size;
-		}
-		
-		@Override
-		public T next()
-		{
-			int i = cursor;
-			if (i >= size)
-			{
-				throw new NoSuchElementException();
-			}
-			cursor = i + 1;
-			lastRet = i;
-			return elementData[lastRet];
-		}
-		
-		@Override
-		public void remove()
-		{
-			throw new UnsupportedOperationException();
-		}
-	}
-	
-	@Override
-	public Object[] toArray()
-	{
-		_rl.lock();
-		try
-		{
-			return _list.toArray();
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-	
-	@Override
-	@SuppressWarnings("hiding")
-	public <T> T[] toArray(T[] a)
-	{
-		_rl.lock();
-		try
-		{
-			return _list.toArray(a);
-		}
-		finally
-		{
-			_rl.unlock();
-		}
-	}
-}

+ 0 - 198
L2J_Server_BETA/java/com/l2jserver/gameserver/util/L2SyncMap.java

@@ -1,198 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import com.l2jserver.util.L2FastMap;
-import com.l2jserver.util.L2FastMap.I2ForEach;
-import com.l2jserver.util.L2FastMap.I2ForEachKey;
-import com.l2jserver.util.L2FastMap.I2ForEachValue;
-
-/**
- * Fully synchronized version of L2FastMap class.<br>
- * In addition it`s provide ForEach methods and interfaces that can be used for iterating collection without using iterators.<br>
- * As addition its provide full lock on entire class if needed<br>
- * <font color="red">WARNING!!! methods: keySet(), values() and entrySet() are removed!</font> <br>
- * @author Julian Version: 1.0.0 <2008-02-07> - Original release
- * @author Julian Varsion: 1.0.1 <2008-06-17> - Changed underlying map to L2FastMap
- * @param <K>
- * @param <V>
- */
-public class L2SyncMap<K extends Object, V extends Object> implements Map<K, V>
-{
-	private final L2FastMap<K, V> _map = new L2FastMap<>();
-	
-	@Override
-	public synchronized V put(K key, V value)
-	{
-		return _map.put(key, value);
-	}
-	
-	@Override
-	public synchronized V get(Object key)
-	{
-		return _map.get(key);
-	}
-	
-	@Override
-	public synchronized V remove(Object key)
-	{
-		return _map.remove(key);
-	}
-	
-	@Override
-	public synchronized boolean containsKey(Object key)
-	{
-		return _map.containsKey(key);
-	}
-	
-	@Override
-	public synchronized int size()
-	{
-		return _map.size();
-	}
-	
-	@Override
-	public synchronized boolean isEmpty()
-	{
-		return _map.isEmpty();
-	}
-	
-	@Override
-	public synchronized void clear()
-	{
-		_map.clear();
-	}
-	
-	/**
-	 * This method use specific locking strategy: map which have lowest hashCode() will be locked first
-	 * @see java.util.Map#putAll(java.util.Map)
-	 */
-	@Override
-	public void putAll(Map<? extends K, ? extends V> map)
-	{
-		if ((map == null) || (this == map))
-		{
-			return;
-		}
-		if (this.hashCode() <= map.hashCode())
-		{
-			synchronized (this)
-			{
-				synchronized (map)
-				{
-					_map.putAll(map);
-				}
-			}
-		}
-		else
-		{
-			synchronized (map)
-			{
-				synchronized (this)
-				{
-					_map.putAll(map);
-				}
-			}
-		}
-	}
-	
-	@Override
-	public synchronized boolean containsValue(Object value)
-	{
-		return _map.containsValue(value);
-	}
-	
-	@Override
-	public synchronized boolean equals(Object o)
-	{
-		return _map.equals(o);
-	}
-	
-	@Override
-	public synchronized int hashCode()
-	{
-		return _map.hashCode();
-	}
-	
-	@Override
-	public synchronized String toString()
-	{
-		return _map.toString();
-	}
-	
-	/**
-	 * Public method that iterate entire collection.<br>
-	 * <br>
-	 * @param func - a class method that must be executed on every element of collection.<br>
-	 * @return - returns true if entire collection is iterated, false if it`s been interrupted by check method (I2ForEach.forEach())<br>
-	 */
-	public synchronized final boolean ForEach(I2ForEach<K, V> func)
-	{
-		return _map.ForEach(func);
-	}
-	
-	public synchronized final boolean ForEachValue(I2ForEachValue<V> func)
-	{
-		return _map.ForEachValue(func);
-	}
-	
-	public synchronized final boolean ForEachKey(I2ForEachKey<K> func)
-	{
-		return _map.ForEachKey(func);
-	}
-	
-	/**
-	 * <font color="red">Unsupported operation!!!</font>
-	 * @deprecated
-	 * @throws UnsupportedOperationException
-	 * @see java.util.Map#values()
-	 */
-	@Override
-	@Deprecated
-	public Collection<V> values()
-	{
-		throw new UnsupportedOperationException();
-	}
-	
-	/**
-	 * <font color="red">Unsupported operation!!!</font>
-	 * @return
-	 * @deprecated
-	 * @throws UnsupportedOperationException
-	 */
-	@Override
-	@Deprecated
-	public Set<K> keySet()
-	{
-		throw new UnsupportedOperationException();
-	}
-	
-	/**
-	 * <font color="red">Unsupported operation!!!</font>
-	 * @deprecated
-	 * @throws UnsupportedOperationException
-	 * @see java.util.Map#entrySet()
-	 */
-	@Override
-	@Deprecated
-	public Set<Map.Entry<K, V>> entrySet()
-	{
-		throw new UnsupportedOperationException();
-	}
-}

+ 0 - 90
L2J_Server_BETA/java/com/l2jserver/gameserver/util/WorldObjectMap.java

@@ -1,90 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javolution.util.FastMap;
-
-import com.l2jserver.gameserver.model.L2Object;
-
-/**
- * This class ...
- * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
- * @param <T>
- */
-public class WorldObjectMap<T extends L2Object> extends L2ObjectMap<T>
-{
-	Map<Integer, T> _objectMap = new FastMap<Integer, T>().shared();
-	
-	@Override
-	public int size()
-	{
-		return _objectMap.size();
-	}
-	
-	@Override
-	public boolean isEmpty()
-	{
-		return _objectMap.isEmpty();
-	}
-	
-	@Override
-	public void clear()
-	{
-		_objectMap.clear();
-	}
-	
-	@Override
-	public void put(T obj)
-	{
-		if (obj != null)
-		{
-			_objectMap.put(obj.getObjectId(), obj);
-		}
-	}
-	
-	@Override
-	public void remove(T obj)
-	{
-		if (obj != null)
-		{
-			_objectMap.remove(obj.getObjectId());
-		}
-	}
-	
-	@Override
-	public T get(int id)
-	{
-		return _objectMap.get(id);
-	}
-	
-	@Override
-	public boolean contains(T obj)
-	{
-		if (obj == null)
-		{
-			return false;
-		}
-		return _objectMap.get(obj.getObjectId()) != null;
-	}
-	
-	@Override
-	public Iterator<T> iterator()
-	{
-		return _objectMap.values().iterator();
-	}
-}

+ 0 - 79
L2J_Server_BETA/java/com/l2jserver/gameserver/util/WorldObjectSet.java

@@ -1,79 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javolution.util.FastMap;
-
-import com.l2jserver.gameserver.model.L2Object;
-
-/**
- * This class ...
- * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
- * @param <T>
- */
-public class WorldObjectSet<T extends L2Object> extends L2ObjectSet<T>
-{
-	private final Map<Integer, T> _objectMap;
-	
-	public WorldObjectSet()
-	{
-		_objectMap = new FastMap<Integer, T>().shared();
-	}
-	
-	@Override
-	public int size()
-	{
-		return _objectMap.size();
-	}
-	
-	@Override
-	public boolean isEmpty()
-	{
-		return _objectMap.isEmpty();
-	}
-	
-	@Override
-	public void clear()
-	{
-		_objectMap.clear();
-	}
-	
-	@Override
-	public void put(T obj)
-	{
-		_objectMap.put(obj.getObjectId(), obj);
-	}
-	
-	@Override
-	public void remove(T obj)
-	{
-		_objectMap.remove(obj.getObjectId());
-	}
-	
-	@Override
-	public boolean contains(T obj)
-	{
-		return _objectMap.containsKey(obj.getObjectId());
-	}
-	
-	@Override
-	public Iterator<T> iterator()
-	{
-		return _objectMap.values().iterator();
-	}
-}

+ 0 - 177
L2J_Server_BETA/java/com/l2jserver/gameserver/util/WorldObjectTree.java

@@ -1,177 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.util;
-
-import java.util.Iterator;
-import java.util.TreeMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import com.l2jserver.gameserver.model.L2Object;
-
-/**
- * @author dishkols
- * @param <T>
- */
-public class WorldObjectTree<T extends L2Object> extends L2ObjectMap<T>
-{
-	private final TreeMap<Integer, T> _objectMap = new TreeMap<>();
-	private final ReentrantReadWriteLock _rwl = new ReentrantReadWriteLock();
-	private final Lock _r = _rwl.readLock();
-	private final Lock _w = _rwl.writeLock();
-	
-	@Override
-	public int size()
-	{
-		_r.lock();
-		try
-		{
-			return _objectMap.size();
-		}
-		finally
-		{
-			_r.unlock();
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.gameserver.util.L2ObjectMap#isEmpty()
-	 */
-	@Override
-	public boolean isEmpty()
-	{
-		_r.lock();
-		try
-		{
-			return _objectMap.isEmpty();
-		}
-		finally
-		{
-			_r.unlock();
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.gameserver.util.L2ObjectMap#clear()
-	 */
-	@Override
-	public void clear()
-	{
-		_w.lock();
-		try
-		{
-			_objectMap.clear();
-		}
-		finally
-		{
-			_w.unlock();
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.gameserver.util.L2ObjectMap#put(L2Object)
-	 */
-	@Override
-	public void put(T obj)
-	{
-		if (obj != null)
-		{
-			_w.lock();
-			try
-			{
-				_objectMap.put(obj.getObjectId(), obj);
-			}
-			finally
-			{
-				_w.unlock();
-			}
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.gameserver.util.L2ObjectMap#remove(L2Object)
-	 */
-	@Override
-	public void remove(T obj)
-	{
-		if (obj != null)
-		{
-			_w.lock();
-			try
-			{
-				_objectMap.remove(obj.getObjectId());
-			}
-			finally
-			{
-				_w.unlock();
-			}
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.gameserver.util.L2ObjectMap#get(int)
-	 */
-	@Override
-	public T get(int id)
-	{
-		_r.lock();
-		try
-		{
-			return _objectMap.get(id);
-		}
-		finally
-		{
-			_r.unlock();
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.gameserver.util.L2ObjectMap#contains(L2Object)
-	 */
-	@Override
-	public boolean contains(T obj)
-	{
-		if (obj == null)
-		{
-			return false;
-		}
-		_r.lock();
-		try
-		{
-			return _objectMap.containsValue(obj);
-		}
-		finally
-		{
-			_r.unlock();
-		}
-	}
-	
-	/**
-	 * @see com.l2jserver.gameserver.util.L2ObjectMap#iterator()
-	 */
-	@Override
-	public Iterator<T> iterator()
-	{
-		_r.lock();
-		try
-		{
-			return _objectMap.values().iterator();
-		}
-		finally
-		{
-			_r.unlock();
-		}
-	}
-}

+ 31 - 19
L2J_Server_BETA/java/com/l2jserver/util/L2FastList.java

@@ -18,52 +18,64 @@ import java.util.List;
 
 import javolution.util.FastList;
 
+import com.l2jserver.gameserver.model.IL2Procedure;
+
 /**
- * A custom version of LinkedList with extension for iterating without using temporary collection<br>
+ * A custom version of FastList with extension for iterating without using temporary collection<br>
  * It`s provide synchronization lock when iterating if needed<br>
  * <br>
- * @author Julian Version 1.0.1 (2008-02-07)<br>
- *         Changes:<br>
- *         1.0.0 - Initial version.<br>
- *         1.0.1 - Made forEachP() final.<br>
+ * @author Julian
+ * @version 1.0.1 (2008-02-07)<br>
+ *          1.0.0 - Initial version.<br>
+ *          1.0.1 - Made forEachP() final.<br>
+ * @author UnAfraid
+ * @version 1.0.2 (20012-08-19)<br>
+ *          1.0.2 - Using IL2Procedure instead of IForEach.
  * @param <T>
  */
 public class L2FastList<T extends Object> extends FastList<T>
 {
-	static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 8354641653178203420L;
 	
-	/**
-	 * Public inner interface used by ForEach iterations<br>
-	 * @author Julian
-	 * @param <T>
-	 */
-	public interface I2ForEach<T>
+	public L2FastList()
 	{
-		public boolean ForEach(T obj);
+		this(false);
 	}
 	
-	public L2FastList()
+	public L2FastList(boolean shared)
 	{
-		super();
+		if (shared)
+		{
+			shared();
+		}
 	}
 	
 	public L2FastList(List<? extends T> list)
+	{
+		this(list, false);
+	}
+	
+	public L2FastList(List<? extends T> list, boolean shared)
 	{
 		super(list);
+		if (shared)
+		{
+			shared();
+		}
 	}
 	
 	/**
 	 * Public method that iterate entire collection.<br>
 	 * <br>
-	 * @param func - a class method that must be executed on every element of collection.<br>
+	 * @param proc - a class method that must be executed on every element of collection.<br>
 	 * @return - returns true if entire collection is iterated, false if it`s been interrupted by<br>
-	 *         check method (I2ForEach.forEach())<br>
+	 *         check method (IL2Procedure.execute(T))<br>
 	 */
-	public boolean forEach(I2ForEach<T> func)
+	public boolean forEach(IL2Procedure<T> proc)
 	{
 		for (T e : this)
 		{
-			if (!func.ForEach(e))
+			if (!proc.execute(e))
 			{
 				return false;
 			}

+ 46 - 22
L2J_Server_BETA/java/com/l2jserver/util/L2FastMap.java

@@ -14,22 +14,56 @@
  */
 package com.l2jserver.util;
 
-import java.util.HashMap;
 import java.util.Map;
 
+import javolution.util.FastMap;
+
+import com.l2jserver.gameserver.model.IL2Procedure;
+
 /**
- * A custom version of HashMap with extension for iterating without using temporary collection<br>
+ * A custom version of FastMap with extension for iterating without using temporary collection<br>
  * <br>
- * @author Julian Version 1.0.1 (2008-02-07)<br>
- *         Changes:<br>
- *         1.0.0 - Initial version.<br>
- *         1.0.1 - Made forEachP() final.<br>
+ * @author Julian
+ * @version 1.0.1 (2008-02-07)<br>
+ *          Changes:<br>
+ *          1.0.0 - Initial version.<br>
+ *          1.0.1 - Made forEachP() final.<br>
+ * @author UnAfraid
+ * @version 1.0.2 (2012-08-19)<br>
+ *          1.0.2 - Using IL2Procedure instead of I2ForEachKey/Value<br>
  * @param <K>
  * @param <V>
  */
-public class L2FastMap<K extends Object, V extends Object> extends HashMap<K, V>
+public class L2FastMap<K extends Object, V extends Object> extends FastMap<K, V>
 {
-	static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 8503855490858805336L;
+	
+	public L2FastMap()
+	{
+		this(false);
+	}
+	
+	public L2FastMap(boolean shared)
+	{
+		if (shared)
+		{
+			shared();
+		}
+	}
+	
+	public L2FastMap(Map<K, V> map)
+	{
+		this(map, false);
+	}
+	
+	public L2FastMap(Map<K, V> map, boolean shared)
+	{
+		super(map);
+		if (shared)
+		{
+			shared();
+		}
+	}
 	
 	/**
 	 * Public inner interface used by ForEach iterations<br>
@@ -42,16 +76,6 @@ public class L2FastMap<K extends Object, V extends Object> extends HashMap<K, V>
 		public boolean forEach(K key, V val);
 	}
 	
-	public interface I2ForEachKey<K>
-	{
-		public boolean forEach(K key);
-	}
-	
-	public interface I2ForEachValue<V>
-	{
-		public boolean forEach(V val);
-	}
-	
 	/**
 	 * Public method that iterate entire collection.<br>
 	 * <br>
@@ -71,11 +95,11 @@ public class L2FastMap<K extends Object, V extends Object> extends HashMap<K, V>
 		return true;
 	}
 	
-	public boolean ForEachKey(I2ForEachKey<K> func)
+	public boolean ForEachKey(IL2Procedure<K> proc)
 	{
 		for (K k : keySet())
 		{
-			if (!func.forEach(k))
+			if (!proc.execute(k))
 			{
 				return false;
 			}
@@ -83,11 +107,11 @@ public class L2FastMap<K extends Object, V extends Object> extends HashMap<K, V>
 		return true;
 	}
 	
-	public boolean ForEachValue(I2ForEachValue<V> func)
+	public boolean ForEachValue(IL2Procedure<V> proc)
 	{
 		for (V v : values())
 		{
-			if (!func.forEach(v))
+			if (!proc.execute(v))
 			{
 				return false;
 			}