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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user