diff options
Diffstat (limited to 'src/main/java/gtPlusPlus/api/objects/data')
7 files changed, 33 insertions, 17 deletions
diff --git a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java index f0687fae4f..92ba97e722 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java @@ -34,6 +34,7 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect /** * Generates an AutoMap from the List. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(List<V> aList) { @@ -45,8 +46,10 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect } } } + /** * Generates an AutoMap from a Set. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Set<V> aList) { @@ -58,8 +61,10 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect } } } + /** * Generates an AutoMap from a Collection. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Collection<V> aList) { @@ -74,6 +79,7 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect /** * Generates an AutoMap from a Array. + * * @param aArray - Data to be inserted into the AutoMap. */ public AutoMap(V[] aArray) { diff --git a/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java b/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java index 698e56ae45..8ec21dab59 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java +++ b/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.data; -import com.google.common.base.Objects; import java.io.Serializable; +import com.google.common.base.Objects; + public class FlexiblePair<K, V> implements Serializable { /** diff --git a/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java b/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java index 1f8a4baa2c..eff314f9ae 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java @@ -6,6 +6,7 @@ import java.util.Arrays; * Object-2-object map based on IntIntMap4a */ public class ObjMap<K, V> { + private static final Object FREE_KEY = new Object(); private static final Object REMOVED_KEY = new Object(); @@ -51,7 +52,7 @@ public class ObjMap<K, V> { if (k == FREE_KEY) return null; // end of chain already if (k.equals(key)) // we check FREE and REMOVED prior to this call - return (V) m_data[ptr + 1]; + return (V) m_data[ptr + 1]; while (true) { ptr = (ptr + 2) & m_mask2; // that's next index k = m_data[ptr]; @@ -72,7 +73,7 @@ public class ObjMap<K, V> { m_data[ptr] = key; m_data[ptr + 1] = value; if (m_size >= m_threshold) rehash(m_data.length * 2); // size is set inside - else ++m_size; + else++m_size; return null; } else if (k.equals(key)) // we check FREE and REMOVED prior to this call { @@ -92,7 +93,7 @@ public class ObjMap<K, V> { m_data[ptr] = key; m_data[ptr + 1] = value; if (m_size >= m_threshold) rehash(m_data.length * 2); // size is set inside - else ++m_size; + else++m_size; return null; } else if (k.equals(key)) { final Object ret = m_data[ptr + 1]; @@ -196,9 +197,11 @@ public class ObjMap<K, V> { /** Taken from FastUtil implementation */ - /** Return the least power of two greater than or equal to the specified value. + /** + * Return the least power of two greater than or equal to the specified value. * - * <p>Note that this function will return 1 when the argument is 0. + * <p> + * Note that this function will return 1 when the argument is 0. * * @param x a long integer smaller than or equal to 2<sup>62</sup>. * @return the least power of two greater than or equal to the specified value. @@ -214,18 +217,19 @@ public class ObjMap<K, V> { return (x | x >> 32) + 1; } - /** Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to <code>Math.ceil( expected / f )</code>. + /** + * Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to + * <code>Math.ceil( expected / f )</code>. * * @param expected the expected number of elements in a hash table. - * @param f the load factor. + * @param f the load factor. * @return the minimum possible size for a backing array. * @throws IllegalArgumentException if the necessary size is larger than 2<sup>30</sup>. */ public static int arraySize(final int expected, final float f) { final long s = Math.max(2, nextPowerOfTwo((long) Math.ceil(expected / f))); - if (s > (1 << 30)) - throw new IllegalArgumentException( - "Too large (" + expected + " expected elements with load factor " + f + ")"); + if (s > (1 << 30)) throw new IllegalArgumentException( + "Too large (" + expected + " expected elements with load factor " + f + ")"); return (int) s; } diff --git a/src/main/java/gtPlusPlus/api/objects/data/Pair.java b/src/main/java/gtPlusPlus/api/objects/data/Pair.java index 33b2ade368..93bf075c8f 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/Pair.java +++ b/src/main/java/gtPlusPlus/api/objects/data/Pair.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.data; -import com.google.common.base.Objects; import java.io.Serializable; +import com.google.common.base.Objects; + public class Pair<K, V> implements Serializable { /** diff --git a/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java b/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java index 6acf62aa53..c282ce1eb3 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java +++ b/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java @@ -1,16 +1,16 @@ package gtPlusPlus.api.objects.data; -import gtPlusPlus.api.objects.Logger; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import gtPlusPlus.api.objects.Logger; + public class TypeCounter<V> implements Set<V> { - private Map<String, InternalTypeCounterObject<V>> mInternalMap = - new LinkedHashMap<String, InternalTypeCounterObject<V>>(); + private Map<String, InternalTypeCounterObject<V>> mInternalMap = new LinkedHashMap<String, InternalTypeCounterObject<V>>(); private String mHighestValueKey; private int mHighestValue = 0; private final Class mClass; @@ -21,6 +21,7 @@ public class TypeCounter<V> implements Set<V> { } public static class InternalTypeCounterObject<Z> { + private final Z mObject; private int mCounter = 0; diff --git a/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java b/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java index 20eed5cdc5..46cb8b35d9 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java +++ b/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java @@ -1,6 +1,5 @@ package gtPlusPlus.api.objects.data; -import gtPlusPlus.api.objects.random.XSTR; import java.util.Collection; import java.util.Map; import java.util.NavigableMap; @@ -8,6 +7,8 @@ import java.util.Random; import java.util.Set; import java.util.TreeMap; +import gtPlusPlus.api.objects.random.XSTR; + public class WeightedCollection<E> implements Map<Integer, E> { private NavigableMap<Integer, E> map = new TreeMap<Integer, E>(); diff --git a/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java index fcf6131611..c9176c00c5 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java @@ -1,9 +1,11 @@ package gtPlusPlus.api.objects.data.weakref; -import gtPlusPlus.api.objects.data.AutoMap; import java.util.WeakHashMap; +import gtPlusPlus.api.objects.data.AutoMap; + public class WeakAutoMap<T> extends AutoMap<T> { + private static final long serialVersionUID = 8328345351801363386L; public WeakAutoMap() { |