|
@@ -18,11 +18,12 @@ import java.util.Map;
|
|
|
|
|
|
import javolution.util.FastMap;
|
|
|
|
|
|
+import com.l2jserver.gameserver.model.IL2EntryProcedure;
|
|
|
import com.l2jserver.gameserver.model.IL2Procedure;
|
|
|
|
|
|
/**
|
|
|
* A custom version of FastMap with extension for iterating without using temporary collection<br>
|
|
|
- * <br>
|
|
|
+ * It's provide synchronization lock when iterating if needed<br>
|
|
|
* @author Julian
|
|
|
* @version 1.0.1 (2008-02-07)<br>
|
|
|
* Changes:<br>
|
|
@@ -34,7 +35,7 @@ import com.l2jserver.gameserver.model.IL2Procedure;
|
|
|
* @param <K>
|
|
|
* @param <V>
|
|
|
*/
|
|
|
-public class L2FastMap<K extends Object, V extends Object> extends FastMap<K, V>
|
|
|
+public class L2FastMap<K, V> extends FastMap<K, V>
|
|
|
{
|
|
|
private static final long serialVersionUID = 8503855490858805336L;
|
|
|
|
|
@@ -43,20 +44,26 @@ public class L2FastMap<K extends Object, V extends Object> extends FastMap<K, V>
|
|
|
this(false);
|
|
|
}
|
|
|
|
|
|
+ public L2FastMap(Map<? extends K, ? extends V> map)
|
|
|
+ {
|
|
|
+ this(map, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ public L2FastMap(int initialCapacity)
|
|
|
+ {
|
|
|
+ this(initialCapacity, false);
|
|
|
+ }
|
|
|
+
|
|
|
public L2FastMap(boolean shared)
|
|
|
{
|
|
|
+ super();
|
|
|
if (shared)
|
|
|
{
|
|
|
shared();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public L2FastMap(Map<K, V> map)
|
|
|
- {
|
|
|
- this(map, false);
|
|
|
- }
|
|
|
-
|
|
|
- public L2FastMap(Map<K, V> map, boolean shared)
|
|
|
+ public L2FastMap(Map<? extends K, ? extends V> map, boolean shared)
|
|
|
{
|
|
|
super(map);
|
|
|
if (shared)
|
|
@@ -65,29 +72,27 @@ public class L2FastMap<K extends Object, V extends Object> extends FastMap<K, V>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Public inner interface used by ForEach iterations<br>
|
|
|
- * @author Julian
|
|
|
- * @param <K>
|
|
|
- * @param <V>
|
|
|
- */
|
|
|
- public interface I2ForEach<K, V>
|
|
|
+ public L2FastMap(int initialCapacity, boolean shared)
|
|
|
{
|
|
|
- public boolean forEach(K key, V val);
|
|
|
+ super(initialCapacity);
|
|
|
+ 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 (IL2EntryProcedure.execute())<br>
|
|
|
*/
|
|
|
- public boolean ForEach(I2ForEach<K, V> func)
|
|
|
+ public boolean executeForEachEntry(IL2EntryProcedure<K, V> proc)
|
|
|
{
|
|
|
for (Map.Entry<K, V> e : entrySet())
|
|
|
{
|
|
|
- if (!func.forEach(e.getKey(), e.getValue()))
|
|
|
+ if (!proc.execute(e.getKey(), e.getValue()))
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
@@ -95,7 +100,7 @@ public class L2FastMap<K extends Object, V extends Object> extends FastMap<K, V>
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public boolean ForEachKey(IL2Procedure<K> proc)
|
|
|
+ public boolean executeForEachKey(IL2Procedure<K> proc)
|
|
|
{
|
|
|
for (K k : keySet())
|
|
|
{
|
|
@@ -107,7 +112,7 @@ public class L2FastMap<K extends Object, V extends Object> extends FastMap<K, V>
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public boolean ForEachValue(IL2Procedure<V> proc)
|
|
|
+ public boolean executeForEachValue(IL2Procedure<V> proc)
|
|
|
{
|
|
|
for (V v : values())
|
|
|
{
|