Refactoring and Deprecating SortedMap/Sets
- Added: OrderedMap/Set - Added: All Relevant functions into Ordered interface - Changed: Marked all Relevant SortedMap/Set functions Deprecated until 0.6.0 - Fixed: All code that was relevant to this
This commit is contained in:
@@ -218,6 +218,7 @@ public class GlobalVariables
|
||||
addClassMapper("LIST_ITER", "ListIter");
|
||||
addClassMapper("LIST", "List");
|
||||
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
||||
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
||||
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
||||
addBiClassMapper("MAP", "Map", "2");
|
||||
addClassMapper("NAVIGABLE_SET", "NavigableSet");
|
||||
@@ -226,6 +227,7 @@ public class GlobalVariables
|
||||
addClassMapper("PRIORITY_DEQUEUE", "PriorityDequeue");
|
||||
addClassMapper("PREDICATE", "2BooleanFunction");
|
||||
addClassMapper("SORTED_SET", "SortedSet");
|
||||
addClassMapper("ORDERED_SET", "OrderedSet");
|
||||
addClassMapper("SET", "Set");
|
||||
addClassMapper("STRATEGY", "Strategy");
|
||||
addClassMapper("STACK", "Stack");
|
||||
|
||||
@@ -73,7 +73,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||
biRequired.put("Pair", "");
|
||||
biRequired.put("MutablePair", "");
|
||||
biRequired.put("ImmutablePair", "");
|
||||
addBiClass("Function", "Maps", "Map", "SortedMap", "NavigableMap", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||
addBiClass("Function", "Maps", "Map", "SortedMap", "OrderedMap", "NavigableMap", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||
nameRemapper.put("BiConsumer", "%sConsumer");
|
||||
nameRemapper.put("IArray", "I%sArray");
|
||||
nameRemapper.put("AbstractMap", "Abstract%sMap");
|
||||
@@ -88,8 +88,8 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||
nameRemapper.put("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||
|
||||
addBlockage(ClassType.OBJECT, "Consumer", "Comparator", "Stack");
|
||||
addBlockage(ClassType.BOOLEAN, "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
||||
addBlockage(ClassType.BOOLEAN, "ImmutableOpenHashMap", "ImmutableOpenHashSet", "SortedMap", "NavigableMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||
addBlockage(ClassType.BOOLEAN, "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "OrderedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
||||
addBlockage(ClassType.BOOLEAN, "ImmutableOpenHashMap", "ImmutableOpenHashSet", "SortedMap", "OrderedMap", "NavigableMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||
}
|
||||
|
||||
protected void create(ClassType mainType, ClassType subType)
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
@@ -71,7 +72,7 @@ import speiger.src.collections.utils.HashUtil;
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE, ORDERED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/** The Backing array for links between nodes. Left 32 Bits => Previous Entry, Right 32 Bits => Next Entry */
|
||||
protected transient long[] links;
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
@@ -70,7 +71,7 @@ import speiger.src.collections.utils.HashUtil;
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE, ORDERED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/** The Backing array for links between nodes. Left 32 Bits => Previous Entry, Right 32 Bits => Next Entry */
|
||||
protected transient long[] links;
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
@@ -83,7 +84,7 @@ import speiger.src.collections.utils.HashUtil;
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE, ORDERED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/** The Backing keys array */
|
||||
protected transient KEY_TYPE[] keys;
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
@@ -42,7 +43,7 @@ import speiger.src.collections.objects.sets.ObjectSet;
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE, ORDERED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/** The Backing array for links between nodes. Left 32 Bits => Previous Entry, Right 32 Bits => Next Entry */
|
||||
protected long[] links;
|
||||
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
/**
|
||||
* A Special Map Interface giving Access to some really usefull functions
|
||||
* The Idea behind this interface is to allow access to functions that give control to the Order of elements.
|
||||
* Since Linked implementations as examples can be reordered outside of the Insertion Order.
|
||||
* This interface provides basic access to such functions while also providing some Sorted/NaivgableMap implementations that still fit into here.
|
||||
*
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/**
|
||||
* A customized put method that allows you to insert into the first index.
|
||||
* @param key the key that should be inserted
|
||||
* @param value the value that should be inserted
|
||||
* @return the previous present or default return value
|
||||
* @see java.util.Map#put(Object, Object)
|
||||
*/
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value);
|
||||
|
||||
/**
|
||||
* A customized put method that allows you to insert into the last index. (This may be nessesary depending on the implementation)
|
||||
* @param key the key that should be inserted
|
||||
* @param value the value that should be inserted
|
||||
* @return the previous present or default return value
|
||||
* @see java.util.Map#put(Object, Object)
|
||||
*/
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value);
|
||||
|
||||
/**
|
||||
* A specific move method to move a given key/value to the first index.
|
||||
* @param key that should be moved to the first index
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
*/
|
||||
public boolean moveToFirst(KEY_TYPE key);
|
||||
/**
|
||||
* A specific move method to move a given key/value to the last index.
|
||||
* @param key that should be moved to the first last
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
*/
|
||||
public boolean moveToLast(KEY_TYPE key);
|
||||
|
||||
/**
|
||||
* A Specific get method that allows to move teh given key/value int the first index.
|
||||
* @param key that is searched for
|
||||
* @return the given value for the requested key or default return value
|
||||
*/
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key);
|
||||
/**
|
||||
* A Specific get method that allows to move teh given key/value int the last index.
|
||||
* @param key that is searched for
|
||||
* @return the given value for the requested key or default return value
|
||||
*/
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key);
|
||||
|
||||
/**
|
||||
* A method to get the first Key of a Map.
|
||||
* @return the first key in the map
|
||||
*/
|
||||
public KEY_TYPE FIRST_ENTRY_KEY();
|
||||
/**
|
||||
* A method to get and remove the first Key of a Map.
|
||||
* @return the first key in the map
|
||||
*/
|
||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY();
|
||||
/**
|
||||
* A method to get the last Key of a Map.
|
||||
* @return the last key in the map
|
||||
*/
|
||||
public KEY_TYPE LAST_ENTRY_KEY();
|
||||
/**
|
||||
* A method to get and remove the last Key of a Map.
|
||||
* @return the last key in the map
|
||||
*/
|
||||
public KEY_TYPE POLL_LAST_ENTRY_KEY();
|
||||
|
||||
/**
|
||||
* A method to get the first Value of a Map.
|
||||
* @return the first key in the map
|
||||
*/
|
||||
public VALUE_TYPE FIRST_ENTRY_VALUE();
|
||||
/**
|
||||
* A method to get the last Value of a Map.
|
||||
* @return the last key in the map
|
||||
*/
|
||||
public VALUE_TYPE LAST_ENTRY_VALUE();
|
||||
|
||||
@Override
|
||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
||||
|
||||
/**
|
||||
* Creates a Wrapped SortedMap that is Synchronized
|
||||
* @return a new SortedMap that is synchronized
|
||||
* @see MAPS#synchronize
|
||||
*/
|
||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize() { return MAPS.synchronize(this); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped SortedMap that is Synchronized
|
||||
* @param mutex is the controller of the synchronization block
|
||||
* @return a new SortedMap Wrapper that is synchronized
|
||||
* @see MAPS#synchronize
|
||||
*/
|
||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(Object mutex) { return MAPS.synchronize(this, mutex); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped SortedMap that is unmodifiable
|
||||
* @return a new SortedMap Wrapper that is unmodifiable
|
||||
* @see MAPS#unmodifiable
|
||||
*/
|
||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||
}
|
||||
+9
-1
@@ -19,8 +19,10 @@ import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||
*
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
* @note ORDERED_MAP is only extended until 0.6.0 for Compat reasons.
|
||||
* The supported classes already implement ORDERED_MAP directly and will remove SORTED_MAP implementations in favor of ORDERED_MAP instead
|
||||
*/
|
||||
public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE, CLASS_VALUE_TYPE>, MAP KEY_VALUE_GENERIC_TYPE
|
||||
public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE, CLASS_VALUE_TYPE>, ORDERED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/**
|
||||
* A customized put method that allows you to insert into the first index.
|
||||
@@ -29,6 +31,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||
* @return the previous present or default return value
|
||||
* @see java.util.Map#put(Object, Object)
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_MAP#putAndMoveToFirst instead (removed in 0.6.0)
|
||||
*/
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value);
|
||||
/**
|
||||
@@ -38,6 +41,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||
* @return the previous present or default return value
|
||||
* @see java.util.Map#put(Object, Object)
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_MAP#putAndMoveToLast instead (removed in 0.6.0)
|
||||
*/
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value);
|
||||
|
||||
@@ -47,6 +51,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_MAP#moveToFirst instead (removed in 0.6.0)
|
||||
*/
|
||||
public boolean moveToFirst(KEY_TYPE key);
|
||||
/**
|
||||
@@ -55,6 +60,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_MAP#moveToLast instead (removed in 0.6.0)
|
||||
*/
|
||||
public boolean moveToLast(KEY_TYPE key);
|
||||
|
||||
@@ -63,6 +69,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||
* @param key that is searched for
|
||||
* @return the given value for the requested key or default return value
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_MAP#getAndMoveToFirst instead (removed in 0.6.0)
|
||||
*/
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key);
|
||||
/**
|
||||
@@ -70,6 +77,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||
* @param key that is searched for
|
||||
* @return the given value for the requested key or default return value
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_MAP#getAndMoveToLast instead (removed in 0.6.0)
|
||||
*/
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
* This implementation does not shrink the backing array
|
||||
* @Type(T)
|
||||
*/
|
||||
public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
||||
public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE, ORDERED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
/** The Backing Array */
|
||||
protected transient KEY_TYPE[] data;
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ import speiger.src.collections.utils.SanityChecks;
|
||||
* This implementation of SortedSet does not support SubSet of any kind. It implements the interface due to sortability and first/last access
|
||||
* @Type(T)
|
||||
*/
|
||||
public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
||||
public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE, ORDERED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
/** The Backing array for links between nodes. Left 32 Bits => Previous Entry, Right 32 Bits => Next Entry */
|
||||
protected transient long[] links;
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import speiger.src.collections.utils.SanityChecks;
|
||||
* This implementation of SortedSet does not support SubSet of any kind. It implements the interface due to sortability and first/last access
|
||||
* @Type(T)
|
||||
*/
|
||||
public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
||||
public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE, ORDERED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
/** The Backing array for links between nodes. Left 32 Bits => Previous Entry, Right 32 Bits => Next Entry */
|
||||
protected transient long[] links;
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package speiger.src.collections.PACKAGE.sets;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
|
||||
/**
|
||||
* A Special Set Interface giving Access to some really usefull functions
|
||||
* The Idea behind this interface is to allow access to functions that give control to the Order of elements.
|
||||
* Since Linked implementations as examples can be reordered outside of the Insertion Order.
|
||||
* This interface provides basic access to such functions while also providing some Sorted/NaivgableSet implementations that still fit into here.
|
||||
*
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE
|
||||
{
|
||||
/**
|
||||
* A customized add method that allows you to insert into the first index.
|
||||
* @param o the element that should be inserted
|
||||
* @return true if it was added
|
||||
* @see java.util.Set#add(Object)
|
||||
*/
|
||||
public boolean addAndMoveToFirst(KEY_TYPE o);
|
||||
/**
|
||||
* A customized add method that allows you to insert into the last index.
|
||||
* @param o the element that should be inserted
|
||||
* @return true if it was added
|
||||
* @see java.util.Set#add(Object)
|
||||
*/
|
||||
public boolean addAndMoveToLast(KEY_TYPE o);
|
||||
|
||||
/**
|
||||
* A specific move method to move a given key to the first index.
|
||||
* @param o that should be moved to the first index
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
*/
|
||||
public boolean moveToFirst(KEY_TYPE o);
|
||||
/**
|
||||
* A specific move method to move a given key to the last index.
|
||||
* @param o that should be moved to the first last
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
*/
|
||||
public boolean moveToLast(KEY_TYPE o);
|
||||
|
||||
@Override
|
||||
public ORDERED_SET KEY_GENERIC_TYPE copy();
|
||||
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
/**
|
||||
* A type Specific Iterator starting from a given key
|
||||
* @param fromElement the element the iterator should start from
|
||||
* @return a iterator starting from the given element
|
||||
* @throws java.util.NoSuchElementException if fromElement isn't found
|
||||
*/
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
|
||||
|
||||
/**
|
||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||
* @return type specific splititerator
|
||||
*/
|
||||
@Override
|
||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
||||
|
||||
/**
|
||||
* A method to get the first element in the set
|
||||
* @return first element in the set
|
||||
*/
|
||||
public KEY_TYPE FIRST_KEY();
|
||||
/**
|
||||
* A method to get and remove the first element in the set
|
||||
* @return first element in the set
|
||||
*/
|
||||
public KEY_TYPE POLL_FIRST_KEY();
|
||||
/**
|
||||
* A method to get the last element in the set
|
||||
* @return last element in the set
|
||||
*/
|
||||
public KEY_TYPE LAST_KEY();
|
||||
/**
|
||||
* A method to get and remove the last element in the set
|
||||
* @return last element in the set
|
||||
*/
|
||||
public KEY_TYPE POLL_LAST_KEY();
|
||||
|
||||
#if !TYPE_BOOLEAN
|
||||
/**
|
||||
* Creates a Wrapped OrderedSet that is Synchronized
|
||||
* @return a new OrderedSet that is synchronized
|
||||
* @see SETS#synchronize
|
||||
*/
|
||||
public default ORDERED_SET KEY_GENERIC_TYPE synchronize() { return SETS.synchronize(this); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped OrderedSet that is Synchronized
|
||||
* @param mutex is the controller of the synchronization block
|
||||
* @return a new OrderedSet Wrapper that is synchronized
|
||||
* @see SETS#synchronize
|
||||
*/
|
||||
public default ORDERED_SET KEY_GENERIC_TYPE synchronize(Object mutex) { return SETS.synchronize(this, mutex); }
|
||||
|
||||
/**
|
||||
* Creates a Wrapped OrderedSet that is unmodifiable
|
||||
* @return a new OrderedSet Wrapper that is unmodifiable
|
||||
* @see SETS#unmodifiable
|
||||
*/
|
||||
public default ORDERED_SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -16,8 +16,10 @@ import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||
* A Type Specific SortedSet implementation to reduce boxing/unboxing
|
||||
* with a couple extra methods that allow greater control over sets.
|
||||
* @Type(T)
|
||||
* @note ORDERED_SET is only extended until 0.6.0 for Compat reasons.
|
||||
* The supported classes already implement ORDERED_SET directly and will remove SORTED_SET implementations in favor of ORDERED_SET instead
|
||||
*/
|
||||
public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, SortedSet<CLASS_TYPE>
|
||||
public interface SORTED_SET KEY_GENERIC_TYPE extends ORDERED_SET KEY_GENERIC_TYPE, SortedSet<CLASS_TYPE>
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -26,6 +28,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
||||
* @return true if it was added
|
||||
* @see java.util.Set#add(Object)
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_SET#addAndMoveToFirst instead (removed in 0.6.0)
|
||||
*/
|
||||
public boolean addAndMoveToFirst(KEY_TYPE o);
|
||||
/**
|
||||
@@ -34,6 +37,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
||||
* @return true if it was added
|
||||
* @see java.util.Set#add(Object)
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_SET#addAndMoveToLast instead (removed in 0.6.0)
|
||||
*/
|
||||
public boolean addAndMoveToLast(KEY_TYPE o);
|
||||
|
||||
@@ -43,6 +47,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_SET#moveToFirst instead (removed in 0.6.0)
|
||||
*/
|
||||
public boolean moveToFirst(KEY_TYPE o);
|
||||
/**
|
||||
@@ -51,6 +56,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
||||
* @return true if the value was moved.
|
||||
* @note returns false if the value was not present in the first place
|
||||
* @note some implementations do not support this method
|
||||
* @deprecated use ORDERED_SET#moveToLast instead (removed in 0.6.0)
|
||||
*/
|
||||
public boolean moveToLast(KEY_TYPE o);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection;
|
||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection;
|
||||
@@ -95,6 +96,29 @@ public class SETS
|
||||
return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Synchronized OrderedSet while preserving the ITrimmable interface
|
||||
* @param s the set that should be synchronized
|
||||
* @Type(T)
|
||||
* @return a OrderedSet that is synchronized
|
||||
* @note if the set is already synchronized then it will just self return it
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ORDERED_SET KEY_GENERIC_TYPE synchronize(ORDERED_SET KEY_GENERIC_TYPE s) {
|
||||
return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s) : new SynchronizedOrderedSetBRACES(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Synchronized OrderedSet while preserving the ITrimmable interface
|
||||
* @param s the set that should be synchronized
|
||||
* @param mutex controller for access
|
||||
* @Type(T)
|
||||
* @return a OrderedSet that is synchronized
|
||||
* @note if the set is already synchronized then it will just self return it
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ORDERED_SET KEY_GENERIC_TYPE synchronize(ORDERED_SET KEY_GENERIC_TYPE s, Object mutex) {
|
||||
return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s, mutex) : new SynchronizedOrderedSetBRACES(s, mutex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface
|
||||
* @param s the set that should be synchronized
|
||||
@@ -138,6 +162,16 @@ public class SETS
|
||||
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Unmodifyable OrderedSet wrapper
|
||||
* @param s OrderedSet that should be made unmodifiable
|
||||
* @Type(T)
|
||||
* @return a UnmodifyableOrderedSet, if the set is already unmodifiable then it returns itself
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ORDERED_SET KEY_GENERIC_TYPE unmodifiable(ORDERED_SET KEY_GENERIC_TYPE s) {
|
||||
return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Unmodifyable NavigableSet wrapper
|
||||
* @param s navigableSet that should be made unmodifiable
|
||||
@@ -278,6 +312,39 @@ public class SETS
|
||||
public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(n.tailSet(fromElement)); }
|
||||
}
|
||||
|
||||
private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
ORDERED_SET KEY_GENERIC_TYPE s;
|
||||
UnmodifiableOrderedSet(ORDERED_SET KEY_GENERIC_TYPE c)
|
||||
{
|
||||
super(c);
|
||||
s = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.unmodifiable(s.iterator()); }
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { return ITERATORS.unmodifiable(s.iterator(fromElement)); }
|
||||
@Override
|
||||
public ORDERED_SET KEY_GENERIC_TYPE copy() { return s.copy(); }
|
||||
@Override
|
||||
public KEY_TYPE FIRST_KEY() { return s.FIRST_KEY(); }
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public KEY_TYPE LAST_KEY() { return s.LAST_KEY(); }
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
||||
private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
SORTED_SET KEY_GENERIC_TYPE s;
|
||||
@@ -288,47 +355,37 @@ public class SETS
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return s.comparator(); }
|
||||
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.unmodifiable(s.iterator()); }
|
||||
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { return ITERATORS.unmodifiable(s.iterator(fromElement)); }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE copy() { return s.copy(); }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) { return SETS.unmodifiable(s.subSet(fromElement, toElement)); }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement) { return SETS.unmodifiable(s.headSet(toElement)); }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(s.tailSet(fromElement)); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE FIRST_KEY() { return s.FIRST_KEY(); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE LAST_KEY() { return s.LAST_KEY(); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
@@ -490,47 +547,96 @@ public class SETS
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean addAndMoveToFirst(KEY_TYPE o) { synchronized(mutex) { return s.addAndMoveToFirst(o); } }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean addAndMoveToLast(KEY_TYPE o) { synchronized(mutex) { return s.addAndMoveToLast(o); } }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToFirst(KEY_TYPE o) { synchronized(mutex) { return s.moveToFirst(o); } }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToLast(KEY_TYPE o) { synchronized(mutex) { return s.moveToLast(o); } }
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator(){ synchronized(mutex) { return s.comparator(); } }
|
||||
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { synchronized(mutex) { return s.iterator(); } }
|
||||
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { synchronized(mutex) { return s.iterator(fromElement); } }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE copy() { synchronized(mutex) { return s.copy(); } }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) { synchronized(mutex) { return SETS.synchronize(s.subSet(fromElement, toElement), mutex); } }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement) { synchronized(mutex) { return SETS.synchronize(s.headSet(toElement), mutex); } }
|
||||
|
||||
@Override
|
||||
public SORTED_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { synchronized(mutex) { return SETS.synchronize(s.tailSet(fromElement), mutex); } }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE FIRST_KEY() { synchronized(mutex) { return s.FIRST_KEY(); } }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_KEY() { synchronized(mutex) { return s.POLL_FIRST_KEY(); } }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE LAST_KEY() { synchronized(mutex) { return s.LAST_KEY(); } }
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
||||
}
|
||||
|
||||
private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable
|
||||
{
|
||||
ITrimmable trim;
|
||||
|
||||
SynchronizedOrderedTrimSet(ORDERED_SET KEY_GENERIC_TYPE c) {
|
||||
super(c);
|
||||
trim = (ITrimmable)c;
|
||||
}
|
||||
|
||||
SynchronizedOrderedTrimSet(ORDERED_SET KEY_GENERIC_TYPE c, Object mutex) {
|
||||
super(c, mutex);
|
||||
trim = (ITrimmable)c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(int size) { synchronized(mutex) { return trim.trim(size); } }
|
||||
|
||||
@Override
|
||||
public void clearAndTrim(int size) { synchronized(mutex) { trim.clearAndTrim(size); } }
|
||||
}
|
||||
|
||||
private static class SynchronizedOrderedSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE
|
||||
{
|
||||
ORDERED_SET KEY_GENERIC_TYPE s;
|
||||
|
||||
SynchronizedOrderedSet(ORDERED_SET KEY_GENERIC_TYPE c) {
|
||||
super(c);
|
||||
s = c;
|
||||
}
|
||||
|
||||
SynchronizedOrderedSet(ORDERED_SET KEY_GENERIC_TYPE c, Object mutex) {
|
||||
super(c, mutex);
|
||||
s = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAndMoveToFirst(KEY_TYPE o) { synchronized(mutex) { return s.addAndMoveToFirst(o); } }
|
||||
@Override
|
||||
public boolean addAndMoveToLast(KEY_TYPE o) { synchronized(mutex) { return s.addAndMoveToLast(o); } }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE o) { synchronized(mutex) { return s.moveToFirst(o); } }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE o) { synchronized(mutex) { return s.moveToLast(o); } }
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { synchronized(mutex) { return s.iterator(); } }
|
||||
@Override
|
||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { synchronized(mutex) { return s.iterator(fromElement); } }
|
||||
@Override
|
||||
public ORDERED_SET KEY_GENERIC_TYPE copy() { synchronized(mutex) { return s.copy(); } }
|
||||
@Override
|
||||
public KEY_TYPE FIRST_KEY() { synchronized(mutex) { return s.FIRST_KEY(); } }
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_KEY() { synchronized(mutex) { return s.POLL_FIRST_KEY(); } }
|
||||
@Override
|
||||
public KEY_TYPE LAST_KEY() { synchronized(mutex) { return s.LAST_KEY(); } }
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
||||
}
|
||||
|
||||
+139
-4
@@ -32,6 +32,7 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||
#if !TYPE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
@@ -161,6 +162,28 @@ public class MAPS
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP KEY_VALUE_GENERIC_TYPE synchronize(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedSortedMap ? map : new SynchronizedSortedMapKV_BRACES(map, mutex); }
|
||||
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the OrderedMap.
|
||||
* @param map the OrderedMap that should be synchronized
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
* @return a synchronized OrderedMap
|
||||
* @note if the inputted map is already synchronized then it will just return it instead
|
||||
* @note iterators do not support synchronization
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map); }
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access with custom access control into the OrderedMap.
|
||||
* @param map the OrderedMap that should be synchronized
|
||||
* @param mutex the object that controls access
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
* @return a synchronized OrderedMap
|
||||
* @note if the inputted map is already synchronized then it will just return it instead
|
||||
* @note iterators do not support synchronization
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map, mutex); }
|
||||
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the NavigableMap.
|
||||
* @param map the NavigableMap that should be synchronized
|
||||
@@ -192,6 +215,17 @@ public class MAPS
|
||||
* @note if the inputted map is already unmodifiable then it will just return it instead
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE unmodifiable(MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableMap ? map : new UnmodifyableMapKV_BRACES(map); }
|
||||
|
||||
/**
|
||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the OrderedMap
|
||||
* @param map the OrderedMap that should be made Unmodifiable
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
* @return a unmodifiable OrderedMap
|
||||
* @note if the inputted OrderedMap is already unmodifiable then it will just return it instead
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableOrderedMap ? map : new UnmodifyableOrderedMapKV_BRACES(map); }
|
||||
|
||||
/**
|
||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the SortedMap
|
||||
* @param map the SortedMap that should be made Unmodifiable
|
||||
@@ -201,6 +235,7 @@ public class MAPS
|
||||
* @note if the inputted SortedMap is already unmodifiable then it will just return it instead
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(SORTED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableSortedMap ? map : new UnmodifyableSortedMapKV_BRACES(map); }
|
||||
|
||||
/**
|
||||
* A Helper function that creates a Helper wrapper to only allow Read Access into NavigableMap Map
|
||||
* @param map the NavigableMap that should be made Unmodifiable
|
||||
@@ -210,6 +245,7 @@ public class MAPS
|
||||
* @note if the inputted NavigableMap is already unmodifiable then it will just return it instead
|
||||
*/
|
||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableNavigableMap ? map : new UnmodifyableNavigableMapKV_BRACES(map); }
|
||||
|
||||
/**
|
||||
* A Helper function that creates a Unmodifyable Entry
|
||||
* @param entry the Entry that should be made unmodifiable
|
||||
@@ -424,14 +460,14 @@ public class MAPS
|
||||
}
|
||||
|
||||
/**
|
||||
* The Unmodifyable Sorted Map implementation that is sued for the unmodifyableMap function
|
||||
* The Unmodifyable Ordered Map implementation that is sued for the unmodifyableMap function
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public static class UnmodifyableSortedMap KEY_VALUE_GENERIC_TYPE extends UnmodifyableMap KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE {
|
||||
SORTED_MAP KEY_VALUE_GENERIC_TYPE map;
|
||||
public static class UnmodifyableOrderedMap KEY_VALUE_GENERIC_TYPE extends UnmodifyableMap KEY_VALUE_GENERIC_TYPE implements ORDERED_MAP KEY_VALUE_GENERIC_TYPE {
|
||||
ORDERED_MAP KEY_VALUE_GENERIC_TYPE map;
|
||||
|
||||
UnmodifyableSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
UnmodifyableOrderedMap(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
super(map);
|
||||
this.map = map;
|
||||
}
|
||||
@@ -449,6 +485,53 @@ public class MAPS
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public KEY_TYPE FIRST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); }
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
||||
@Override
|
||||
public KEY_TYPE LAST_ENTRY_KEY() { return map.LAST_ENTRY_KEY(); }
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() { return map.POLL_LAST_ENTRY_KEY(); }
|
||||
@Override
|
||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
||||
@Override
|
||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
||||
@Override
|
||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
||||
/**
|
||||
* The Unmodifyable Sorted Map implementation that is sued for the unmodifyableMap function
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public static class UnmodifyableSortedMap KEY_VALUE_GENERIC_TYPE extends UnmodifyableMap KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE {
|
||||
SORTED_MAP KEY_VALUE_GENERIC_TYPE map;
|
||||
|
||||
UnmodifyableSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
super(map);
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return map.comparator(); }
|
||||
@Override
|
||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, KEY_TYPE toKey) { return MAPS.unmodifiable(map.subMap(fromKey, toKey)); }
|
||||
@@ -680,6 +763,52 @@ public class MAPS
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* The Synchronized Ordered Map implementation used by the synchronizedMap helper function
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
public static class SynchronizedOrderedMap KEY_VALUE_GENERIC_TYPE extends SynchronizedMap KEY_VALUE_GENERIC_TYPE implements ORDERED_MAP KEY_VALUE_GENERIC_TYPE {
|
||||
ORDERED_MAP KEY_VALUE_GENERIC_TYPE map;
|
||||
|
||||
SynchronizedOrderedMap(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
super(map);
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
SynchronizedOrderedMap(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) {
|
||||
super(map, mutex);
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putAndMoveToFirst(key, value); } }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putAndMoveToLast(key, value); } }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { synchronized(mutex) { return map.moveToFirst(key); } }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { synchronized(mutex) { return map.moveToLast(key); } }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { synchronized(mutex) { return map.getAndMoveToFirst(key); } }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { synchronized(mutex) { return map.getAndMoveToLast(key); } }
|
||||
@Override
|
||||
public KEY_TYPE FIRST_ENTRY_KEY() { synchronized(mutex) { return map.FIRST_ENTRY_KEY(); } }
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { synchronized(mutex) { return map.POLL_FIRST_ENTRY_KEY(); } }
|
||||
@Override
|
||||
public KEY_TYPE LAST_ENTRY_KEY() { synchronized(mutex) { return map.LAST_ENTRY_KEY(); } }
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() { synchronized(mutex) { return map.POLL_LAST_ENTRY_KEY(); } }
|
||||
@Override
|
||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { synchronized(mutex) { return map.FIRST_ENTRY_VALUE(); } }
|
||||
@Override
|
||||
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
||||
@Override
|
||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
|
||||
/**
|
||||
* The Synchronized Sorted Map implementation used by the synchronizedMap helper function
|
||||
* @Type(T)
|
||||
@@ -699,16 +828,22 @@ public class MAPS
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putAndMoveToFirst(key, value); } }
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putAndMoveToLast(key, value); } }
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToFirst(KEY_TYPE key) { synchronized(mutex) { return map.moveToFirst(key); } }
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean moveToLast(KEY_TYPE key) { synchronized(mutex) { return map.moveToLast(key); } }
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { synchronized(mutex) { return map.getAndMoveToFirst(key); } }
|
||||
@Override
|
||||
@Deprecated
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { synchronized(mutex) { return map.getAndMoveToLast(key); } }
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { synchronized(mutex) { return map.comparator(); } }
|
||||
|
||||
Reference in New Issue
Block a user