Few changes.

-Removed: BooleanSet classes are gone. (Unused anyways)
-Removed: Boolean2xMaps are also now gone. (Unused Anyways)
-Added: GlobalFlags that are shared across packages.
This commit is contained in:
2022-12-05 07:10:53 +01:00
parent cc87cae145
commit c9fc963670
12 changed files with 729 additions and 88 deletions
@@ -20,7 +20,7 @@ import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif
import speiger.src.collections.PACKAGE.utils.ARRAYS;
#if LIST_FEATURE
#if LISTS_FEATURE
import speiger.src.collections.PACKAGE.utils.LISTS;
#endif
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
@@ -28,16 +28,17 @@ import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
#endif
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
#if OBJECT_ASYNC_MODULE
import speiger.src.collections.PACKAGE.lists.LIST;
#endif
#if ARRAY_LIST_FEATURE
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
#else if LINKED_LIST_FEATURE
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
#endif
#if !TYPE_BOOLEAN
#if !TYPE_BOOLEAN && OBJECT_ASYNC_MODULE
import speiger.src.collections.PACKAGE.sets.SET;
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
#endif
#endif
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
@@ -2,6 +2,7 @@ package speiger.src.collections.PACKAGE.utils;
import java.util.Arrays;
import java.util.Collection;
import java.util.NoSuchElementException;
import java.util.Objects;
#if TYPE_OBJECT
import java.util.Comparator;
@@ -84,6 +85,16 @@ public class COLLECTIONS
return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex);
}
/**
* Creates a Singleton Collection of a given element
* @param element the element that should be converted into a singleton collection
* @Type(T)
* @return a singletoncollection of the given element
*/
public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE singleton(KEY_TYPE element) {
return new SingletonCollectionBRACES(element);
}
protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
return new CollectionWrapperBRACES();
}
@@ -278,6 +289,42 @@ public class COLLECTIONS
#endif
}
private static class SingletonCollection KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE
{
KEY_TYPE element;
SingletonCollection(KEY_TYPE element) {
this.element = element;
}
#if !TYPE_OBJECT
@Override
public boolean REMOVE_KEY(KEY_TYPE o) { throw new UnsupportedOperationException(); }
#endif
@Override
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
@Override
public ITERATOR KEY_GENERIC_TYPE iterator()
{
return new ITERATOR KEY_GENERIC_TYPE() {
boolean next = true;
@Override
public boolean hasNext() { return next; }
@Override
public KEY_TYPE NEXT() {
if(!hasNext()) throw new NoSuchElementException();
next = false;
return element;
}
};
}
@Override
public int size() { return 1; }
@Override
public SingletonCollection KEY_GENERIC_TYPE copy() { return new SingletonCollectionBRACES(element); }
}
/**
* Synchronized Collection Wrapper for the synchronizedCollection function
* @Type(T)
@@ -22,6 +22,7 @@ import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
#else if LINKED_LIST_FEATURE
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
#endif
import speiger.src.collections.PACKAGE.lists.LIST;
#endif
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
@@ -49,9 +49,6 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER
#endif
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_COLLECTIONS;
#if !SAME_TYPE && !VALUE_OBJECT
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_SETS;
#endif
#endif
/**
@@ -344,7 +341,7 @@ public class MAPS
@Override
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
if(values == null) values = VALUE_SETS.singleton(value);
if(values == null) values = VALUE_COLLECTIONS.singleton(value);
return values;
}
@Override