Finished first loop of JavaDoc generation.

-Fixed: A couple bugs that were found during javadoc generation.

Next loop of javadoc comes later right now i want to add splititerators
and streams
This commit is contained in:
2021-04-26 22:25:09 +02:00
parent f7d311fd09
commit a9a38f7853
22 changed files with 1173 additions and 212 deletions
@@ -19,6 +19,9 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
*/
public class COLLECTIONS
{
/**
* Empty Collection Reference
*/
public static final COLLECTION NO_GENERIC_TYPE EMPTY = new EmptyCollectionBRACES();
/**
@@ -65,6 +68,10 @@ public class COLLECTIONS
return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex);
}
/**
* Synchronized Collection Wrapper for the synchronizedCollection function
* @Type(T)
*/
public static class SynchronizedCollection KEY_GENERIC_TYPE implements COLLECTION KEY_GENERIC_TYPE {
COLLECTION KEY_GENERIC_TYPE c;
protected Object mutex;
@@ -163,6 +170,10 @@ public class COLLECTIONS
#endif
}
/**
* Unmodifyable Collection Wrapper for the unmodifyableCollection method
* @Type(T)
*/
public static class UnmodifiableCollection KEY_GENERIC_TYPE implements COLLECTION KEY_GENERIC_TYPE {
COLLECTION KEY_GENERIC_TYPE c;
@@ -284,6 +295,10 @@ public class COLLECTIONS
#endif
}
/**
* Empty Collection implementation for the empty collection function
* @Type(T)
*/
public static class EmptyCollection KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE {
@Override
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
@@ -10,6 +10,9 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
*/
public class ITERATORS
{
/**
* Empty Iterator Reference
*/
public static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES();
/**
@@ -25,42 +28,24 @@ public class ITERATORS
#endif
}
/**
* Inverter function for Bidirectional Iterators
* @param it the iterator that should be inverted
* @Type(T)
* @return a Inverted Bidirectional Iterator. If it was inverted then it just gives back the original reference
*/
public static GENERIC_KEY_BRACES BI_ITERATOR KEY_GENERIC_TYPE invert(BI_ITERATOR KEY_GENERIC_TYPE it) {
return new BI_ITERATOR KEY_GENERIC_TYPE() {
@Override
public KEY_TYPE NEXT() { return it.PREVIOUS(); }
@Override
public boolean hasNext() { return it.hasPrevious(); }
@Override
public boolean hasPrevious() { return it.hasNext(); }
@Override
public KEY_TYPE PREVIOUS() { return it.NEXT(); }
@Override
public void remove() { it.remove(); }
};
return it instanceof ReverseBiIterator ? ((ReverseBiIterator KEY_GENERIC_TYPE)it).it : new ReverseBiIteratorBRACES(it);
}
/**
* Inverter function for List Iterators
* @param it the iterator that should be inverted
* @Type(T)
* @return a Inverted List Iterator. If it was inverted then it just gives back the original reference
*/
public static GENERIC_KEY_BRACES LIST_ITERATOR KEY_GENERIC_TYPE invert(LIST_ITERATOR KEY_GENERIC_TYPE it) {
return new LIST_ITERATOR KEY_GENERIC_TYPE() {
@Override
public KEY_TYPE NEXT() { return it.PREVIOUS(); }
@Override
public boolean hasNext() { return it.hasPrevious(); }
@Override
public boolean hasPrevious() { return it.hasNext(); }
@Override
public KEY_TYPE PREVIOUS() { return it.NEXT(); }
@Override
public void remove() { it.remove(); }
@Override
public int nextIndex() { return it.previousIndex(); }
@Override
public int previousIndex() { return it.nextIndex(); }
@Override
public void set(KEY_TYPE e) { it.set(e); }
@Override
public void add(KEY_TYPE e) { it.add(e); }
};
return it instanceof ReverseListIterator ? ((ReverseListIterator KEY_GENERIC_TYPE)it).it : new ReverseListIteratorBRACES(it);
}
/**
@@ -73,6 +58,12 @@ public class ITERATORS
return iterator instanceof UnmodifiableIterator ? iterator : new UnmodifiableIteratorBRACES(iterator);
}
/**
* Returns a Immutable Iterator instance based on the instance given.
* @param iterator that should be made immutable/unmodifyable
* @Type(T)
* @return a unmodifiable iterator wrapper. If the Iterator already a unmodifyable wrapper then it just returns itself.
*/
public static GENERIC_KEY_BRACES BI_ITERATOR KEY_GENERIC_TYPE unmodifiable(BI_ITERATOR KEY_GENERIC_TYPE iterator) {
return iterator instanceof UnmodifiableBiIterator ? iterator : new UnmodifiableBiIteratorBRACES(iterator);
}
@@ -88,6 +79,11 @@ public class ITERATORS
}
#if !TYPE_OBJECT
/**
* Helper function to convert a Object Iterator into a Primitive Iterator
* @param iterator that should be converted to a unboxing iterator
* @return a primitive iterator
*/
public static ITERATOR wrap(Iterator<CLASS_TYPE> iterator) {
return iterator instanceof ITERATOR ? (ITERATOR)iterator : new IteratorWrapper(iterator);
}
@@ -271,6 +267,52 @@ public class ITERATORS
}
#endif
private static class ReverseBiIterator KEY_GENERIC_TYPE implements BI_ITERATOR KEY_GENERIC_TYPE {
BI_ITERATOR KEY_GENERIC_TYPE it;
ReverseBiIterator(BI_ITERATOR KEY_GENERIC_TYPE it) {
this.it = it;
}
@Override
public KEY_TYPE NEXT() { return it.PREVIOUS(); }
@Override
public boolean hasNext() { return it.hasPrevious(); }
@Override
public boolean hasPrevious() { return it.hasNext(); }
@Override
public KEY_TYPE PREVIOUS() { return it.NEXT(); }
@Override
public void remove() { it.remove(); }
}
private static class ReverseListIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE {
LIST_ITERATOR KEY_GENERIC_TYPE it;
ReverseListIterator(LIST_ITERATOR KEY_GENERIC_TYPE it) {
this.it = it;
}
@Override
public KEY_TYPE NEXT() { return it.PREVIOUS(); }
@Override
public boolean hasNext() { return it.hasPrevious(); }
@Override
public boolean hasPrevious() { return it.hasNext(); }
@Override
public KEY_TYPE PREVIOUS() { return it.NEXT(); }
@Override
public void remove() { it.remove(); }
@Override
public int nextIndex() { return it.previousIndex(); }
@Override
public int previousIndex() { return it.nextIndex(); }
@Override
public void set(KEY_TYPE e) { it.set(e); }
@Override
public void add(KEY_TYPE e) { it.add(e); }
}
private static class UnmodifiableListIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
{
LIST_ITERATOR KEY_GENERIC_TYPE iter;
@@ -18,6 +18,9 @@ import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
*/
public class LISTS
{
/**
* Empty List reference
*/
public static final EmptyList NO_GENERIC_TYPE EMPTY = new EmptyListBRACES();
/**
@@ -74,11 +77,11 @@ public class LISTS
return new SingletonListBRACES(element);
}
public static class SingletonList KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
private static class SingletonList KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
{
KEY_TYPE element;
public SingletonList(KEY_TYPE element)
SingletonList(KEY_TYPE element)
{
this.element = element;
}
@@ -123,7 +126,7 @@ public class LISTS
public int size() { return 1; }
}
public static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE
private static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE
{
IARRAY KEY_GENERIC_TYPE l;
@@ -155,7 +158,7 @@ public class LISTS
}
}
public static class SynchronizedRandomAccessList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements RandomAccess
private static class SynchronizedRandomAccessList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements RandomAccess
{
SynchronizedRandomAccessList(LIST KEY_GENERIC_TYPE l) {
super(l);
@@ -166,7 +169,7 @@ public class LISTS
}
}
public static class SynchronizedList KEY_GENERIC_TYPE extends COLLECTIONS.SynchronizedCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
private static class SynchronizedList KEY_GENERIC_TYPE extends COLLECTIONS.SynchronizedCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
{
LIST KEY_GENERIC_TYPE l;
@@ -271,14 +274,14 @@ public class LISTS
public void size(int size) { synchronized(mutex) { l.size(size); } }
}
public static class UnmodifiableRandomList KEY_GENERIC_TYPE extends UnmodifiableList KEY_GENERIC_TYPE implements RandomAccess
private static class UnmodifiableRandomList KEY_GENERIC_TYPE extends UnmodifiableList KEY_GENERIC_TYPE implements RandomAccess
{
UnmodifiableRandomList(LIST KEY_GENERIC_TYPE l) {
super(l);
}
}
public static class UnmodifiableList KEY_GENERIC_TYPE extends COLLECTIONS.UnmodifiableCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
private static class UnmodifiableList KEY_GENERIC_TYPE extends COLLECTIONS.UnmodifiableCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
{
final LIST KEY_GENERIC_TYPE l;
@@ -380,7 +383,7 @@ public class LISTS
public void size(int size) { throw new UnsupportedOperationException(); }
}
public static class EmptyList KEY_GENERIC_TYPE extends COLLECTIONS.EmptyCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
private static class EmptyList KEY_GENERIC_TYPE extends COLLECTIONS.EmptyCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
{
@Override
public boolean addAll(int index, Collection<? extends CLASS_TYPE> c) { throw new UnsupportedOperationException(); }
@@ -25,10 +25,21 @@ import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection;
import speiger.src.collections.utils.ITrimmable;
#endif
/**
* A Helper class for sets
*/
public class SETS
{
/**
* Empty Set Variable
*/
public static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES();
/**
* EmptySet getter
* @Type(T)
* @return a EmptySet
*/
public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE empty() {
#if TYPE_OBJECT
return (SET<KEY_TYPE>)EMPTY;
@@ -38,52 +49,121 @@ public class SETS
}
#if !TYPE_BOOLEAN
/**
* Creates a Synchronized set while preserving the ITrimmable interface
* @param s the set that should be synchronized
* @Type(T)
* @return a set that is synchronized
* @note if the set is already synchronized then it will just self return it
*/
public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE synchronizedSet(SET KEY_GENERIC_TYPE s) {
return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s) : new SynchronizedSetBRACES(s));
}
/**
* Creates a Synchronized set while preserving the ITrimmable interface
* @param s the set that should be synchronized
* @param mutex controller for access
* @Type(T)
* @return a set that is synchronized
* @note if the set is already synchronized then it will just self return it
*/
public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE synchronizedSet(SET KEY_GENERIC_TYPE s, Object mutex) {
return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex));
}
/**
* Creates a Synchronized SortedSet while preserving the ITrimmable interface
* @param s the set that should be synchronized
* @Type(T)
* @return a SortedSet that is synchronized
* @note if the set is already synchronized then it will just self return it
*/
public static GENERIC_KEY_BRACES SORTED_SET KEY_GENERIC_TYPE synchronizedSet(SORTED_SET KEY_GENERIC_TYPE s) {
return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s) : new SynchronizedSortedSetBRACES(s));
}
/**
* Creates a Synchronized SortedSet while preserving the ITrimmable interface
* @param s the set that should be synchronized
* @param mutex controller for access
* @Type(T)
* @return a SortedSet that is synchronized
* @note if the set is already synchronized then it will just self return it
*/
public static GENERIC_KEY_BRACES SORTED_SET KEY_GENERIC_TYPE synchronizedSet(SORTED_SET KEY_GENERIC_TYPE s, Object mutex) {
return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex));
}
/**
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface
* @param s the set that should be synchronized
* @Type(T)
* @return a NavigableSet that is synchronized
* @note if the set is already synchronized then it will just self return it
*/
public static GENERIC_KEY_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE synchronizedSet(NAVIGABLE_SET KEY_GENERIC_TYPE s) {
return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s) : new SynchronizedNavigableSetBRACES(s));
}
/**
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface
* @param s the set that should be synchronized
* @param mutex controller for access
* @Type(T)
* @return a NavigableSet that is synchronized
* @note if the set is already synchronized then it will just self return it
*/
public static GENERIC_KEY_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE synchronizedSet(NAVIGABLE_SET KEY_GENERIC_TYPE s, Object mutex) {
return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex));
}
/**
* Creates Unmodifyable Set wrapper
* @param s set that should be made unmodifyable
* @Type(T)
* @return a UnmodifyableSet, if the set is already unmodifyable then it returns itself
*/
public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE unmodifiable(SET KEY_GENERIC_TYPE s) {
return s instanceof SynchronizedSet ? s : new SynchronizedSetBRACES(s);
return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s);
}
/**
* Creates Unmodifyable SortedSet wrapper
* @param s sortedSet that should be made unmodifyable
* @Type(T)
* @return a UnmodifyableSortedSet, if the set is already unmodifyable then it returns itself
*/
public static GENERIC_KEY_BRACES SORTED_SET KEY_GENERIC_TYPE unmodifiable(SORTED_SET KEY_GENERIC_TYPE s) {
return s instanceof SynchronizedSortedSet ? s : new SynchronizedSortedSetBRACES(s);
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
}
/**
* Creates Unmodifyable NavigableSet wrapper
* @param s navigableSet that should be made unmodifyable
* @Type(T)
* @return a UnmodifyableNavigableSet, if the set is already unmodifyable then it returns itself
*/
public static GENERIC_KEY_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE unmodifiable(NAVIGABLE_SET KEY_GENERIC_TYPE s) {
return s instanceof UnmodifiableNavigableSet ? s : new UnmodifiableNavigableSetBRACES(s);
}
#endif
/**
* Creates a Singleton set of a given element
* @param element the element that should be converted into a singleton set
* @Type(T)
* @return a singletonset of the given element
*/
public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE singletonSet(KEY_TYPE element) {
return new SingletonSetBRACES(element);
}
public static class SingletonSet KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
private static class SingletonSet KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
{
KEY_TYPE element;
public SingletonSet(KEY_TYPE element) {
SingletonSet(KEY_TYPE element) {
this.element = element;
}
@@ -112,7 +192,7 @@ public class SETS
public int size() { return 1; }
}
public static class EmptySet KEY_GENERIC_TYPE extends EmptyCollection KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
private static class EmptySet KEY_GENERIC_TYPE extends EmptyCollection KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
{
#if !TYPE_OBJECT
@Override
@@ -121,11 +201,11 @@ public class SETS
}
#if !TYPE_BOOLEAN
public 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;
public UnmodifiableNavigableSet(NAVIGABLE_SET KEY_GENERIC_TYPE c) {
UnmodifiableNavigableSet(NAVIGABLE_SET KEY_GENERIC_TYPE c) {
super(c);
n = c;
}
@@ -190,10 +270,10 @@ public class SETS
public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return unmodifiable(n.tailSet(fromElement)); }
}
public 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;
public UnmodifiableSortedSet(SORTED_SET KEY_GENERIC_TYPE c)
UnmodifiableSortedSet(SORTED_SET KEY_GENERIC_TYPE c)
{
super(c);
s = c;
@@ -242,11 +322,15 @@ public class SETS
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
}
/**
* Unmodifyable Set wrapper that helps is used with unmodifyableSet function
* @Type(T)
*/
public static class UnmodifiableSet KEY_GENERIC_TYPE extends UnmodifiableCollection KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
{
SET KEY_GENERIC_TYPE s;
public UnmodifiableSet(SET KEY_GENERIC_TYPE c)
protected UnmodifiableSet(SET KEY_GENERIC_TYPE c)
{
super(c);
s = c;
@@ -258,16 +342,16 @@ public class SETS
#endif
}
public 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;
public SynchronizedNavigableTrimSet(NAVIGABLE_SET KEY_GENERIC_TYPE c) {
SynchronizedNavigableTrimSet(NAVIGABLE_SET KEY_GENERIC_TYPE c) {
super(c);
trim = (ITrimmable)c;
}
public SynchronizedNavigableTrimSet(NAVIGABLE_SET KEY_GENERIC_TYPE c, Object mutex) {
SynchronizedNavigableTrimSet(NAVIGABLE_SET KEY_GENERIC_TYPE c, Object mutex) {
super(c, mutex);
trim = (ITrimmable)c;
}
@@ -276,16 +360,16 @@ public class SETS
public boolean trim(int size) { synchronized(mutex) { return trim.trim(size); } }
}
public static class SynchronizedNavigableSet KEY_GENERIC_TYPE extends SynchronizedSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE
private static class SynchronizedNavigableSet KEY_GENERIC_TYPE extends SynchronizedSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE
{
NAVIGABLE_SET KEY_GENERIC_TYPE n;
public SynchronizedNavigableSet(NAVIGABLE_SET KEY_GENERIC_TYPE c) {
SynchronizedNavigableSet(NAVIGABLE_SET KEY_GENERIC_TYPE c) {
super(c);
n = c;
}
public SynchronizedNavigableSet(NAVIGABLE_SET KEY_GENERIC_TYPE c, Object mutex) {
SynchronizedNavigableSet(NAVIGABLE_SET KEY_GENERIC_TYPE c, Object mutex) {
super(c, mutex);
n = c;
}
@@ -350,16 +434,16 @@ public class SETS
public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { synchronized(mutex) { return synchronizedSet(n.tailSet(fromElement), mutex); } }
}
public static class SynchronizedSortedTrimSet KEY_GENERIC_TYPE extends SynchronizedSortedSet KEY_GENERIC_TYPE implements ITrimmable
private static class SynchronizedSortedTrimSet KEY_GENERIC_TYPE extends SynchronizedSortedSet KEY_GENERIC_TYPE implements ITrimmable
{
ITrimmable trim;
public SynchronizedSortedTrimSet(SORTED_SET KEY_GENERIC_TYPE c) {
SynchronizedSortedTrimSet(SORTED_SET KEY_GENERIC_TYPE c) {
super(c);
trim = (ITrimmable)c;
}
public SynchronizedSortedTrimSet(SORTED_SET KEY_GENERIC_TYPE c, Object mutex) {
SynchronizedSortedTrimSet(SORTED_SET KEY_GENERIC_TYPE c, Object mutex) {
super(c, mutex);
trim = (ITrimmable)c;
}
@@ -368,16 +452,16 @@ public class SETS
public boolean trim(int size) { synchronized(mutex) { return trim.trim(size); } }
}
public static class SynchronizedSortedSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
private static class SynchronizedSortedSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
{
SORTED_SET KEY_GENERIC_TYPE s;
public SynchronizedSortedSet(SORTED_SET KEY_GENERIC_TYPE c) {
SynchronizedSortedSet(SORTED_SET KEY_GENERIC_TYPE c) {
super(c);
s = c;
}
public SynchronizedSortedSet(SORTED_SET KEY_GENERIC_TYPE c, Object mutex) {
SynchronizedSortedSet(SORTED_SET KEY_GENERIC_TYPE c, Object mutex) {
super(c, mutex);
s = c;
}
@@ -425,16 +509,16 @@ public class SETS
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
}
public 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;
public SynchronizedTrimSet(SET KEY_GENERIC_TYPE c) {
SynchronizedTrimSet(SET KEY_GENERIC_TYPE c) {
super(c);
trim = (ITrimmable)c;
}
public SynchronizedTrimSet(SET KEY_GENERIC_TYPE c, Object mutex) {
SynchronizedTrimSet(SET KEY_GENERIC_TYPE c, Object mutex) {
super(c, mutex);
trim = (ITrimmable)c;
}
@@ -443,18 +527,24 @@ public class SETS
public boolean trim(int size) { synchronized(mutex) { return trim.trim(size); } }
}
public static class SynchronizedSet KEY_GENERIC_TYPE extends SynchronizedCollection KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
private static class SynchronizedSet KEY_GENERIC_TYPE extends SynchronizedCollection KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
{
#if !TYPE_OBJECT
SET KEY_GENERIC_TYPE s;
#endif
public SynchronizedSet(SET KEY_GENERIC_TYPE c) {
SynchronizedSet(SET KEY_GENERIC_TYPE c) {
super(c);
#if !TYPE_OBJECT
s = c;
#endif
}
public SynchronizedSet(SET KEY_GENERIC_TYPE c, Object mutex) {
SynchronizedSet(SET KEY_GENERIC_TYPE c, Object mutex) {
super(c, mutex);
#if !TYPE_OBJECT
s = c;
#endif
}
#if !TYPE_OBJECT
@@ -1,8 +1,23 @@
package speiger.src.collections.PACKAGE.utils;
/**
* A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps
* @Type(T)
*/
public interface STRATEGY KEY_GENERIC_TYPE
{
/**
* Type Specific HashCode function
* @param o the element that the hashcode is requested for (if object may be null)
* @return hashcode for the given entry
*/
public int hashCode(KEY_TYPE o);
/**
* Type Specific Equals function
* @param key the first element that should be compared with
* @param value the second element that should be compared with (if object may be null)
* @return if the elements match
*/
public boolean equals(KEY_TYPE key, KEY_TYPE value);
}
@@ -62,8 +62,10 @@ public class MAPS
#endif
/**
* Helper method that provides the fastIterator that recycles a single Entry to increase throughput.
* @param map the map the fastiterator should be accessed from
* @return either a normal iterator if it does not support this feature ot a fastiterator
* @param map the map the fastIterator should be accessed from
* @Type(T)
* @ValueType(V)
* @return either a normal iterator if it does not support this feature to a fastIterator
*/
public static GENERIC_KEY_VALUE_BRACES ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator(MAP KEY_VALUE_GENERIC_TYPE map) {
ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entries = map.ENTRY_SET();
@@ -73,7 +75,9 @@ public class MAPS
/**
* Helper method that provides the fastIterable that recycles a single Entry to increase throughput.
* @param map the map the fastIterable should be accessed from
* @return either a normal iterable if it does not support this feature ot a fastIterable
* @Type(T)
* @ValueType(V)
* @return either a normal iterable if it does not support this feature to a fastIterable
*/
public static GENERIC_KEY_VALUE_BRACES ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterable(MAP KEY_VALUE_GENERIC_TYPE map) {
ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entries = map.ENTRY_SET();
@@ -89,6 +93,8 @@ public class MAPS
* A Helper function that provides a faster forEach iterator implementation that recycles the entry to increase throughput
* @param map the map the fast forEach should be accessed from
* @param action the action that should be performed on each entry
* @Type(T)
* @ValueType(V)
* @note if the fast forEach is not supported will default to a normal forEach
*/
public static GENERIC_KEY_VALUE_BRACES void fastForEach(MAP KEY_VALUE_GENERIC_TYPE map, Consumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
@@ -100,6 +106,8 @@ public class MAPS
#if !TYPE_BOOLEAN
/**
* Empty Map getter function that autocasts to the desired Key and Value
* @Type(T)
* @ValueType(V)
* @return empty map of desired type
*/
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE emptyMap() {
@@ -113,6 +121,8 @@ public class MAPS
/**
* Helper function that creates a Helper wrapper to synchronize access into the map.
* @param map the map that should be synchronized
* @Type(T)
* @ValueType(V)
* @return a synchronized Map
* @note if the inputted map is already synchronized then it will just return it instead
* @note iterators do not support synchronization
@@ -122,6 +132,8 @@ public class MAPS
* Helper function that creates a Helper wrapper to synchronize access with custom access control into the map.
* @param map the map that should be synchronized
* @param mutex the object that controls access
* @Type(T)
* @ValueType(V)
* @return a synchronized Map
* @note if the inputted map is already synchronized then it will just return it instead
* @note iterators do not support synchronization
@@ -131,6 +143,8 @@ public class MAPS
/**
* Helper function that creates a Helper wrapper to synchronize access into the SortedMap.
* @param map the SortedMap that should be synchronized
* @Type(T)
* @ValueType(V)
* @return a synchronized SortedMap
* @note if the inputted map is already synchronized then it will just return it instead
* @note iterators do not support synchronization
@@ -140,6 +154,8 @@ public class MAPS
* Helper function that creates a Helper wrapper to synchronize access with custom access control into the SortedMap.
* @param map the SortedMap that should be synchronized
* @param mutex the object that controls access
* @Type(T)
* @ValueType(V)
* @return a synchronized SortedMap
* @note if the inputted map is already synchronized then it will just return it instead
* @note iterators do not support synchronization
@@ -149,6 +165,8 @@ public class MAPS
/**
* Helper function that creates a Helper wrapper to synchronize access into the NavigableMap.
* @param map the NavigableMap that should be synchronized
* @Type(T)
* @ValueType(V)
* @return a synchronized NavigableMap
* @note if the inputted map is already synchronized then it will just return it instead
* @note iterators do not support synchronization
@@ -158,6 +176,8 @@ public class MAPS
* Helper function that creates a Helper wrapper to synchronize access with custom access control into the NavigableMap.
* @param map the NavigableMap that should be synchronized
* @param mutex the object that controls access
* @Type(T)
* @ValueType(V)
* @return a synchronized NavigableMap
* @note if the inputted map is already synchronized then it will just return it instead
* @note iterators do not support synchronization
@@ -167,6 +187,8 @@ public class MAPS
/**
* A Helper function that creates a Helper wrapper to only allow Read Access into the Map
* @param map the map that should be made Unmodifiable
* @Type(T)
* @ValueType(V)
* @return a unmodifiable Map
* @note if the inputted map is already unmodifiable then it will just return it instead
*/
@@ -174,6 +196,8 @@ public class MAPS
/**
* 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
* @Type(T)
* @ValueType(V)
* @return a unmodifiable SortedMap
* @note if the inputted SortedMap is already unmodifiable then it will just return it instead
*/
@@ -181,6 +205,8 @@ public class MAPS
/**
* 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
* @Type(T)
* @ValueType(V)
* @return a unmodifiable NavigableMap
* @note if the inputted NavigableMap is already unmodifiable then it will just return it instead
*/
@@ -188,12 +214,16 @@ public class MAPS
/**
* A Helper function that creates a Unmodifyable Entry
* @param entry the Entry that should be made unmodifyable
* @Type(T)
* @ValueType(V)
* @return a Unmodifyable Entry
*/
public static GENERIC_KEY_VALUE_BRACES MAP.Entry KEY_VALUE_GENERIC_TYPE unmodifyableEntry(MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { return entry instanceof UnmodifyableEntry ? entry : new UnmodifyableEntryKV_BRACES(entry); }
/**
* A Helper function that creates a Unmodifyable Entry
* @param entry the Entry that should be made unmodifyable
* @Type(T)
* @ValueType(V)
* @return a Unmodifyable Entry
*/
public static GENERIC_KEY_VALUE_BRACES MAP.Entry KEY_VALUE_GENERIC_TYPE unmodifyableEntry(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) { return entry instanceof UnmodifyableEntry ? (UnmodifyableEntry KEY_VALUE_GENERIC_TYPE)entry : new UnmodifyableEntryKV_BRACES(entry); }
@@ -203,6 +233,8 @@ public class MAPS
* This reduces overhead that normal Map implementations have.
* @param key the key that should be turned into a singleton
* @param value the value that should be turned into a singleton
* @Type(T)
* @ValueType(V)
* @return a unmodifyable Singleton map.
*/
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE singletonMap(KEY_TYPE key, VALUE_TYPE value) { return new SingletonMapKV_BRACES(key, value); }
@@ -219,12 +251,7 @@ public class MAPS
VALUE_COLLECTION VALUE_GENERIC_TYPE values;
ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
/**
* Default constructor
* @param key the key that should be used
* @param value the value that should be used
*/
public SingletonMap(KEY_TYPE key, VALUE_TYPE value) {
SingletonMap(KEY_TYPE key, VALUE_TYPE value) {
this.key = key;
this.value = value;
}
@@ -308,19 +335,11 @@ public class MAPS
*/
public static class UnmodifyableEntry KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP.BasicEntry KEY_VALUE_GENERIC_TYPE {
/**
* The boxed constructor that will automatically unbox the values
* @param entry the entry that should be used
*/
public UnmodifyableEntry(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) {
UnmodifyableEntry(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) {
super(entry.getKey(), entry.getValue());
}
/**
* The Unboxed constructor that should be copied from
* @param entry the entry that should be used
*/
public UnmodifyableEntry(MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
UnmodifyableEntry(MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
super(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
}
@@ -336,11 +355,7 @@ public class MAPS
public static class UnmodifyableNavigableMap KEY_VALUE_GENERIC_TYPE extends UnmodifyableSortedMap KEY_VALUE_GENERIC_TYPE implements NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE {
NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map;
/**
* Default constructor
* @param map the NavigableMap that should be made unmodifyable
*/
public UnmodifyableNavigableMap(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) {
UnmodifyableNavigableMap(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) {
super(map);
this.map = map;
}
@@ -407,11 +422,7 @@ public class MAPS
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;
/**
* Default constructor
* @param map the SortedMap that should be made unmodifyable
*/
public UnmodifyableSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map) {
UnmodifyableSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map) {
super(map);
this.map = map;
}
@@ -461,11 +472,7 @@ public class MAPS
SET KEY_GENERIC_TYPE keys;
ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
/**
* Default constructor
* @param map the Map that should be made unmodifyable
*/
public UnmodifyableMap(MAP KEY_VALUE_GENERIC_TYPE map) {
UnmodifyableMap(MAP KEY_VALUE_GENERIC_TYPE map) {
this.map = map;
}
@@ -518,11 +525,7 @@ public class MAPS
{
ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> s;
/**
* Default constructor
* @param c the EntrySet that should be made unmodifyable
*/
public UnmodifyableEntrySet(ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> c)
UnmodifyableEntrySet(ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> c)
{
super(c);
s = c;
@@ -554,21 +557,12 @@ public class MAPS
public static class SynchronizedNavigableMap KEY_VALUE_GENERIC_TYPE extends SynchronizedSortedMap KEY_VALUE_GENERIC_TYPE implements NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE {
NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map;
/**
* Default constructor
* @param map the map that should be synchronized
*/
public SynchronizedNavigableMap(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) {
SynchronizedNavigableMap(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) {
super(map);
this.map = map;
}
/**
* Constructor with Access Control
* @param map the map that should be synchronized
* @param mutex the access controller
*/
public SynchronizedNavigableMap(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) {
SynchronizedNavigableMap(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) {
super(map, mutex);
this.map = map;
}
@@ -677,21 +671,12 @@ public class MAPS
public static class SynchronizedSortedMap KEY_VALUE_GENERIC_TYPE extends SynchronizedMap KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE {
SORTED_MAP KEY_VALUE_GENERIC_TYPE map;
/**
* Default constructor
* @param map the map that should be synchronized
*/
public SynchronizedSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map) {
SynchronizedSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map) {
super(map);
this.map = map;
}
/**
* Constructor with Access Control
* @param map the map that should be synchronized
* @param mutex the access controller
*/
public SynchronizedSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) {
SynchronizedSortedMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) {
super(map, mutex);
this.map = map;
}
@@ -760,21 +745,12 @@ public class MAPS
protected Object mutex;
/**
* Default constructor
* @param map the map that should be synchronized
*/
public SynchronizedMap(MAP KEY_VALUE_GENERIC_TYPE map) {
SynchronizedMap(MAP KEY_VALUE_GENERIC_TYPE map) {
this.map = map;
mutex = this;
}
/**
* Constructor with Access Control
* @param map the map that should be synchronized
* @param mutex the access controller
*/
public SynchronizedMap(MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) {
SynchronizedMap(MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) {
this.map = map;
this.mutex = mutex;
}