99% of the Set Module done.

The 1% is the Distinct Iterator that relies on a Set implementation.
So I have to make a dedicated set implementation.
This commit is contained in:
Speiger 2022-12-06 04:57:43 +01:00
parent 2ed090e989
commit d44ad2d42e
10 changed files with 167 additions and 50 deletions

View File

@ -4,10 +4,10 @@
"Collection": true, "Collection": true,
"Function": true, "Function": true,
"List": true, "List": true,
"Map": true, "Map": false,
"Pair": true, "Pair": true,
"PriorityQueue": true, "PriorityQueue": true,
"Set": true, "Set": false,
"Boolean": { "Boolean": {
"Enabled": true, "Enabled": true,
"Base": { "Base": {
@ -367,15 +367,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },
@ -638,15 +638,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },
@ -909,15 +909,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },
@ -1180,15 +1180,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },
@ -1451,15 +1451,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },
@ -1722,15 +1722,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },
@ -1993,15 +1993,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },
@ -2264,15 +2264,15 @@
}, },
"Set": { "Set": {
"Enabled": true, "Enabled": true,
"LinkedHashSet": true, "LinkedHashSet": false,
"LinkedCustomHashSet": true, "LinkedCustomHashSet": false,
"OrderedSet": true, "OrderedSet": true,
"ArraySet": true, "ArraySet": true,
"AVLTreeSet": true, "AVLTreeSet": true,
"ImmutableSet": true, "ImmutableSet": true,
"CustomHashSet": true, "CustomHashSet": true,
"Sets": true, "Sets": true,
"SortedSet": true, "SortedSet": false,
"HashSet": true, "HashSet": true,
"RBTreeSet": true "RBTreeSet": true
}, },

View File

@ -239,8 +239,8 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
boolean force = flags.contains("force"); boolean force = flags.contains("force");
boolean tests = flags.contains("tests"); boolean tests = flags.contains("tests");
boolean forceTests = flags.contains("force-tests"); boolean forceTests = flags.contains("force-tests");
boolean load = flags.contains("load"); boolean load = !flags.contains("load");
boolean save = !flags.contains("save"); boolean save = flags.contains("save");
int flag = (load ? LOAD : 0) | (save ? SAVE : 0); int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force); new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
if(tests) { if(tests) {

View File

@ -25,9 +25,25 @@ import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
import speiger.src.collections.PACKAGE.lists.LINKED_LIST; import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
#endif #endif
#endif #endif
#if !TYPE_BOOLEAN #if SET_MODULE && !TYPE_BOOLEAN
import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.SET;
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
#if LINKED_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
#else if LINKED_CUSTOM_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
#else if SET_FEATURE
import speiger.src.collections.PACKAGE.sets.HASH_SET;
#else if CUSTOM_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
#else if RB_TREE_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
#else if AVL_TREE_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
#else if ARRAY_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
#endif
#endif
#endif #endif
import speiger.src.collections.PACKAGE.utils.ARRAYS; import speiger.src.collections.PACKAGE.utils.ARRAYS;
#if ASYNC_MODULE #if ASYNC_MODULE
@ -36,6 +52,9 @@ import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
import speiger.src.collections.PACKAGE.utils.ITERABLES; import speiger.src.collections.PACKAGE.utils.ITERABLES;
import speiger.src.collections.PACKAGE.utils.ITERATORS; import speiger.src.collections.PACKAGE.utils.ITERATORS;
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
import speiger.src.collections.PACKAGE.utils.STRATEGY;
#endif
import speiger.src.collections.utils.ISizeProvider; import speiger.src.collections.utils.ISizeProvider;
/** /**
@ -227,17 +246,32 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
} }
#endif #endif
#if !TYPE_BOOLEAN #if !TYPE_BOOLEAN && SET_MODULE
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
/** /**
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet * A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
* @return a new LinkedHashSet of all elements * @return a new LinkedHashSet of all elements
*/ */
default SET KEY_GENERIC_TYPE pourAsSet() { default SET KEY_GENERIC_TYPE pourAsSet() {
return pour(new LINKED_HASH_SETBRACES()); #if LINKED_SET_FEATURE
return pour(new LINKED_HASH_SETBRACES());
#else if LINKED_CUSTOM_SET_FEATURE
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
#else if SET_FEATURE
return pour(new HASH_SETBRACES());
#else if CUSTOM_SET_FEATURE
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
#else if RB_TREE_SET_FEATURE
return pour(new RB_Tree_SETBRACES());
#else if AVL_TREE_SET_FEATURE
return pour(new AVL_Tree_SETBRACES());
#else if ARRAY_SET_FEATURE
return pour(new ARRAY_SETBRACES());
#endif
} }
#endif #endif
#endif
#if TYPE_OBJECT #if TYPE_OBJECT
/** /**
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array * A Helper function that reduces the usage of streams and allows to collect all elements as a Array

View File

@ -4,7 +4,9 @@ import java.util.NavigableSet;
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
#if SETS_FEATURE
import speiger.src.collections.PACKAGE.utils.SETS; import speiger.src.collections.PACKAGE.utils.SETS;
#endif
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
/** /**
@ -119,7 +121,7 @@ public interface NAVIGABLE_SET KEY_GENERIC_TYPE extends NavigableSet<CLASS_TYPE>
@Override @Override
public NAVIGABLE_SET KEY_GENERIC_TYPE copy(); public NAVIGABLE_SET KEY_GENERIC_TYPE copy();
#if !TYPE_BOOLEAN #if SETS_FEATURE
/** /**
* Creates a Wrapped NavigableSet that is Synchronized * Creates a Wrapped NavigableSet that is Synchronized
* @return a new NavigableSet that is synchronized * @return a new NavigableSet that is synchronized

View File

@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.sets;
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
#if SETS_FEATURE
import speiger.src.collections.PACKAGE.utils.SETS; import speiger.src.collections.PACKAGE.utils.SETS;
#endif
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
/** /**
@ -87,7 +89,7 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE
*/ */
public KEY_TYPE POLL_LAST_KEY(); public KEY_TYPE POLL_LAST_KEY();
#if !TYPE_BOOLEAN #if SETS_FEATURE
/** /**
* Creates a Wrapped OrderedSet that is Synchronized * Creates a Wrapped OrderedSet that is Synchronized
* @return a new OrderedSet that is synchronized * @return a new OrderedSet that is synchronized

View File

@ -5,7 +5,7 @@ import java.util.Set;
import speiger.src.collections.PACKAGE.collections.COLLECTION; import speiger.src.collections.PACKAGE.collections.COLLECTION;
import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.collections.ITERATOR;
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
#if !TYPE_BOOLEAN #if SETS_FEATURE
import speiger.src.collections.PACKAGE.utils.SETS; import speiger.src.collections.PACKAGE.utils.SETS;
#endif #endif
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
@ -64,7 +64,7 @@ public interface SET KEY_GENERIC_TYPE extends Set<CLASS_TYPE>, COLLECTION KEY_GE
public KEY_TYPE addOrGet(KEY_TYPE o); public KEY_TYPE addOrGet(KEY_TYPE o);
#endif #endif
#if !TYPE_BOOLEAN #if SETS_FEATURE
/** /**
* Creates a Wrapped Set that is Synchronized * Creates a Wrapped Set that is Synchronized
* @return a new Set that is synchronized * @return a new Set that is synchronized

View File

@ -9,7 +9,9 @@ import java.util.Comparator;
#else #else
import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif #endif
#if SETS_FEATURE
import speiger.src.collections.PACKAGE.utils.SETS; import speiger.src.collections.PACKAGE.utils.SETS;
#endif
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
/** /**
@ -41,7 +43,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
*/ */
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement); public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
#if !TYPE_BOOLEAN #if SETS_FEATURE
/** /**
* Creates a Wrapped SortedSet that is Synchronized * Creates a Wrapped SortedSet that is Synchronized
* @return a new SortedSet that is synchronized * @return a new SortedSet that is synchronized

View File

@ -36,8 +36,26 @@ import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
import speiger.src.collections.PACKAGE.lists.LINKED_LIST; import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
#endif #endif
#if !TYPE_BOOLEAN && OBJECT_ASYNC_MODULE #if !TYPE_BOOLEAN && OBJECT_ASYNC_MODULE
#if SET_MODULE
import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.SET;
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
#if LINKED_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
#else if LINKED_CUSTOM_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
#else if SET_FEATURE
import speiger.src.collections.PACKAGE.sets.HASH_SET;
#else if CUSTOM_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
#else if RB_TREE_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
#else if AVL_TREE_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
#else if ARRAY_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
#endif
#endif
#endif
#endif #endif
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE #if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder; import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
@ -288,15 +306,31 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
} }
#endif #endif
#if !TYPE_BOOLEAN #if !TYPE_BOOLEAN && SET_MODULE
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
/** /**
* Pours all elements into a Set that can be later * Pours all elements into a Set that can be later
* @return a new Builder with the pour function applied * @return a new Builder with the pour function applied
*/ */
public ObjectAsyncBuilder<SET KEY_GENERIC_TYPE> pourAsSet() { public ObjectAsyncBuilder<SET KEY_GENERIC_TYPE> pourAsSet() {
#if LINKED_SET_FEATURE
return pour(new LINKED_HASH_SETBRACES()); return pour(new LINKED_HASH_SETBRACES());
#else if LINKED_CUSTOM_SET_FEATURE
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
#else if SET_FEATURE
return pour(new HASH_SETBRACES());
#else if CUSTOM_SET_FEATURE
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
#else if RB_TREE_SET_FEATURE
return pour(new RB_Tree_SETBRACES());
#else if AVL_TREE_SET_FEATURE
return pour(new AVL_Tree_SETBRACES());
#else if ARRAY_SET_FEATURE
return pour(new ARRAY_SETBRACES());
#endif
} }
#endif
#endif #endif
/** /**
* Pours all elements into a collection that can be later * Pours all elements into a collection that can be later

View File

@ -2,31 +2,30 @@ package speiger.src.collections.PACKAGE.utils;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
#if TYPE_BOOLEAN #if TYPE_OBJECT && SORTED_SET_FEATURE
import speiger.src.collections.booleans.collections.BooleanIterator;
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
import speiger.src.collections.booleans.sets.BooleanSet;
import speiger.src.collections.booleans.utils.BooleanCollections.EmptyCollection;
#else
#if TYPE_OBJECT
import java.util.Comparator; import java.util.Comparator;
#endif #endif
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
#if !TYPE_OBJECT #if !TYPE_OBJECT && SORTED_SET_FEATURE
import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif #endif
import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.collections.ITERATOR;
#if SORTED_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET; import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
#endif
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET; import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.SET;
#if ORDERED_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.ORDERED_SET; import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
#endif
#if SORTED_SET_FEATURE
import speiger.src.collections.PACKAGE.sets.SORTED_SET; import speiger.src.collections.PACKAGE.sets.SORTED_SET;
#endif
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection; import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection;
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection; import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection;
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection; import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection;
import speiger.src.collections.utils.ITrimmable; import speiger.src.collections.utils.ITrimmable;
#endif
/** /**
* A Helper class for sets * A Helper class for sets
@ -51,7 +50,6 @@ public class SETS
#endif #endif
} }
#if !TYPE_BOOLEAN
/** /**
* Creates a Synchronized set while preserving the ITrimmable interface * Creates a Synchronized set while preserving the ITrimmable interface
* @param s the set that should be synchronized * @param s the set that should be synchronized
@ -75,6 +73,7 @@ public class SETS
return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex)); return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex));
} }
#if SORTED_SET_FEATURE
/** /**
* Creates a Synchronized SortedSet while preserving the ITrimmable interface * Creates a Synchronized SortedSet while preserving the ITrimmable interface
* @param s the set that should be synchronized * @param s the set that should be synchronized
@ -98,6 +97,8 @@ public class SETS
return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex)); return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex));
} }
#endif
#if ORDERED_SET_FEATURE
/** /**
* Creates a Synchronized OrderedSet while preserving the ITrimmable interface * Creates a Synchronized OrderedSet while preserving the ITrimmable interface
* @param s the set that should be synchronized * @param s the set that should be synchronized
@ -121,6 +122,8 @@ public class SETS
return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s, mutex) : new SynchronizedOrderedSetBRACES(s, mutex)); return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s, mutex) : new SynchronizedOrderedSetBRACES(s, mutex));
} }
#endif
#if SORTED_SET_FEATURE
/** /**
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface * Creates a Synchronized NavigableSet while preserving the ITrimmable interface
* @param s the set that should be synchronized * @param s the set that should be synchronized
@ -144,6 +147,7 @@ public class SETS
return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex)); return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex));
} }
#endif
/** /**
* Creates Unmodifyable Set wrapper * Creates Unmodifyable Set wrapper
* @param s set that should be made unmodifiable * @param s set that should be made unmodifiable
@ -154,6 +158,7 @@ public class SETS
return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s); return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s);
} }
#if SORTED_SET_FEATURE
/** /**
* Creates Unmodifyable SortedSet wrapper * Creates Unmodifyable SortedSet wrapper
* @param s sortedSet that should be made unmodifiable * @param s sortedSet that should be made unmodifiable
@ -164,6 +169,8 @@ public class SETS
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s); return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
} }
#endif
#if ORDERED_SET_FEATURE
/** /**
* Creates Unmodifyable OrderedSet wrapper * Creates Unmodifyable OrderedSet wrapper
* @param s OrderedSet that should be made unmodifiable * @param s OrderedSet that should be made unmodifiable
@ -174,6 +181,8 @@ public class SETS
return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s); return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s);
} }
#endif
#if SORTED_SET_FEATURE
/** /**
* Creates Unmodifyable NavigableSet wrapper * Creates Unmodifyable NavigableSet wrapper
* @param s navigableSet that should be made unmodifiable * @param s navigableSet that should be made unmodifiable
@ -254,7 +263,7 @@ public class SETS
public EmptySet KEY_GENERIC_TYPE copy() { return this; } public EmptySet KEY_GENERIC_TYPE copy() { return this; }
} }
#if !TYPE_BOOLEAN #if SORTED_SET_FEATURE
private static class UnmodifiableNavigableSet KEY_GENERIC_TYPE extends UnmodifiableSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE private static class UnmodifiableNavigableSet KEY_GENERIC_TYPE extends UnmodifiableSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE
{ {
NAVIGABLE_SET KEY_GENERIC_TYPE n; NAVIGABLE_SET KEY_GENERIC_TYPE n;
@ -340,6 +349,8 @@ public class SETS
public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(n.tailSet(fromElement)); } public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(n.tailSet(fromElement)); }
} }
#endif
#if ORDERED_SET_FEATURE
private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE
{ {
ORDERED_SET KEY_GENERIC_TYPE s; ORDERED_SET KEY_GENERIC_TYPE s;
@ -373,6 +384,8 @@ public class SETS
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); } public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
} }
#endif
#if SORTED_SET_FEATURE
private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
{ {
SORTED_SET KEY_GENERIC_TYPE s; SORTED_SET KEY_GENERIC_TYPE s;
@ -406,6 +419,7 @@ public class SETS
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); } public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
} }
#endif
/** /**
* Unmodifyable Set wrapper that helps is used with unmodifyableSet function * Unmodifyable Set wrapper that helps is used with unmodifyableSet function
* @Type(T) * @Type(T)
@ -434,6 +448,7 @@ public class SETS
#endif #endif
} }
#if SORTED_SET_FEATURE
private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable
{ {
ITrimmable trim; ITrimmable trim;
@ -597,6 +612,8 @@ public class SETS
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } } public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
} }
#endif
#if ORDERED_SET_FEATURE
private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable
{ {
ITrimmable trim; ITrimmable trim;
@ -656,6 +673,7 @@ public class SETS
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } } public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
} }
#endif
private static class SynchronizedTrimSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ITrimmable private static class SynchronizedTrimSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ITrimmable
{ {
ITrimmable trim; ITrimmable trim;
@ -704,5 +722,4 @@ public class SETS
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } } public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
#endif #endif
} }
#endif
} }

View File

@ -1,5 +1,7 @@
package speiger.src.collections.PACKAGE.utils; package speiger.src.collections.PACKAGE.utils;
import java.util.Objects;
/** /**
* A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps * A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps
* @Type(T) * @Type(T)
@ -19,6 +21,17 @@ public interface STRATEGY KEY_GENERIC_TYPE
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY<KEY_TYPE>)IDENTITY; } public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY<KEY_TYPE>)IDENTITY; }
#endif #endif
/**
* Normal Strategy
*/
public static final STRATEGY NO_GENERIC_TYPE NORMAL = new NormalStrategyBRACES();
/**
* @Type(T)
* @return a Normal Strategy that is behaving exactly like the normal Hash Strategy in the Hash Collections
*/
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE normalStrategy() { return (STRATEGY KEY_GENERIC_TYPE)NORMAL; }
/** /**
* Type Specific HashCode function * Type Specific HashCode function
* @param o the element that the hashcode is requested for (if object may be null) * @param o the element that the hashcode is requested for (if object may be null)
@ -47,5 +60,18 @@ public interface STRATEGY KEY_GENERIC_TYPE
@Override @Override
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; } public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; }
} }
#endif #endif
/**
* A Strategy that simulates the normal Hash Collection Behavior if you want to use Hash Control Collections to replace normal ones.
* Only real reason to do that is you have to use this and want to get rid of implementations.
* @Type(T)
*/
public static class NormalStrategy KEY_GENERIC_TYPE implements STRATEGY KEY_GENERIC_TYPE
{
@Override
public int hashCode(KEY_TYPE o) { return KEY_TO_HASH(o); }
@Override
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return EQUALS_KEY_TYPE(key, value); }
}
} }