forked from Speiger/Primitive-Collections
Map Tests & BugFixes.
-Added: Tests for all map implementations. -Added: Missing Map Constructors. -Fixed: Bugs with Maps & Sets. -Fixed: Gradle Java Container. -Fixed: Some javadoc stuff. -Note: SubMap/List implementation are not really well tested and most likely buggy -Changed: set JavaDoc to be quiet for now. Later goal.
This commit is contained in:
parent
aaee550ea9
commit
0b11c3929a
12
.classpath
12
.classpath
|
@ -26,6 +26,18 @@
|
|||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/builder" path="src/builder/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="builder"/>
|
||||
<attribute name="gradle_used_by_scope" value="builder"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/builder" path="src/builder/resources">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="builder"/>
|
||||
<attribute name="gradle_used_by_scope" value="builder"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
|
|
29
.project
29
.project
|
@ -1,23 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Primitive-Collections</name>
|
||||
<comment>Project Primitive-Collections created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<comment></comment>
|
||||
<projects/>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<linkedResources/>
|
||||
<filteredResources/>
|
||||
</projectDescription>
|
||||
|
|
14
build.gradle
14
build.gradle
|
@ -18,6 +18,10 @@ repositories {
|
|||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
||||
|
||||
javadoc {
|
||||
options.tags = [ "implSpec", "note" ]
|
||||
}
|
||||
|
||||
eclipse {
|
||||
classpath {
|
||||
downloadJavadoc = true
|
||||
|
@ -31,6 +35,12 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.compilerArgs << '-XDignore.symbol.file'
|
||||
options.fork = true // may not needed on 1.8
|
||||
options.forkOptions.executable = 'javac' // may not needed on 1.8
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
builder
|
||||
}
|
||||
|
@ -62,9 +72,11 @@ task srcJar(type: Jar) {
|
|||
}
|
||||
|
||||
javadoc.failOnError = false
|
||||
//javadoc.options.showAll()
|
||||
javadoc.options.quiet()
|
||||
|
||||
artifacts {
|
||||
archives javadocJar
|
||||
// archives javadocJar
|
||||
archives srcJar
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||
|
||||
/**
|
||||
* A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
|
||||
* @param value that should be searched for.
|
||||
* @param e the element that should be searched for.
|
||||
* @return true if the value was found.
|
||||
*/
|
||||
@Override
|
||||
|
@ -66,9 +66,9 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||
|
||||
/**
|
||||
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
||||
* @param the collection that should be checked if it contains all elements.
|
||||
* @param c the collection that should be checked if it contains all elements.
|
||||
* @return true if all elements were found in the collection
|
||||
* @throws NullPointerException if the collection is null
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
|
@ -84,7 +84,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||
* @param c the elements that should be checked for
|
||||
* @return true if any element is in this collection
|
||||
* @deprecated if this is a primitive collection
|
||||
* @throws NullPointerException if the collection is null
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
@Primitive
|
||||
|
@ -100,7 +100,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection.
|
||||
* @param c the elements that should be checked for
|
||||
* @return true if any element is in this collection
|
||||
* @throws NullPointerException if the collection is null
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
|
@ -142,7 +142,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||
* A Type-Specific implementation of removeAll. This Implementation iterates over all elements and removes them as they were found in the other collection.
|
||||
* @param c the elements that should be deleted
|
||||
* @return true if the collection was modified.
|
||||
* @throws NullPointerException if the collection is null
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
|
@ -161,7 +161,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||
* A Type-Specific implementation of retainAll. This Implementation iterates over all elements and removes them as they were not found in the other collection.
|
||||
* @param c the elements that should be kept
|
||||
* @return true if the collection was modified.
|
||||
* @throws NullPointerException if the collection is null
|
||||
* @throws java.lang.NullPointerException if the collection is null
|
||||
*/
|
||||
@Override
|
||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public interface BI_ITERATOR KEY_GENERIC_TYPE extends ITERATOR KEY_GENERIC_TYPE
|
|||
/**
|
||||
* Returns the Previous element of the iterator.
|
||||
* @return the Previous element of the iterator.
|
||||
* @throws NoSuchElementException if the iteration has no more elements
|
||||
* @throws java.util.NoSuchElementException if the iteration has no more elements
|
||||
*/
|
||||
public KEY_TYPE PREVIOUS();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific add function to reduce (un)boxing
|
||||
* @see Collection#add(Object)
|
||||
* @param o the element that should be added
|
||||
* @return true if the element was added to the collection
|
||||
*/
|
||||
public boolean add(KEY_TYPE o);
|
||||
|
@ -27,7 +27,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
#endif
|
||||
/**
|
||||
* A Type-Specific addAll function to reduce (un)boxing
|
||||
* @see Collection#addAll(Collection)
|
||||
* @param c the collection of elements that should be added
|
||||
* @return true if elements were added into the collection
|
||||
*/
|
||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
@ -35,7 +35,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific contains function to reduce (un)boxing
|
||||
* @see Collection#contains(Object)
|
||||
* @param o the element that is checked for
|
||||
* @return true if the element is found in the collection
|
||||
*/
|
||||
public boolean contains(KEY_TYPE o);
|
||||
|
@ -43,14 +43,14 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
#endif
|
||||
/**
|
||||
* A Type-Specific containsAll function to reduce (un)boxing
|
||||
* @see Collection#containsAll(Object)
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if all the element is found in the collection
|
||||
*/
|
||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
/**
|
||||
* A Type-Specific containsAny function to reduce (un)boxing
|
||||
* @see #containsAny(Collection)
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if any element was found
|
||||
*/
|
||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
@ -58,6 +58,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
/**
|
||||
* Returns true if any element of the Collection is found in the provided collection.
|
||||
* A Small Optimization function to find out of any element is present when comparing collections and not all of them.
|
||||
* @param c the collection of elements that should be tested for
|
||||
* @return true if any element was found.
|
||||
*/
|
||||
@Primitive
|
||||
|
@ -66,6 +67,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type-Specific remove function that reduces (un)boxing.
|
||||
* @param o the element that should be removed
|
||||
* @return true if the element was removed
|
||||
* @see Collection#remove(Object)
|
||||
*/
|
||||
|
@ -74,6 +76,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
#endif
|
||||
/**
|
||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||
* @param c the collection of elements that should be removed
|
||||
* @return true if any element was removed
|
||||
* @see Collection#removeAll(Collection)
|
||||
*/
|
||||
|
@ -81,6 +84,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
|
||||
/**
|
||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||
* @param c the collection of elements that should be kept
|
||||
* @return true if any element was removed
|
||||
* @see Collection#retainAll(Collection)
|
||||
*/
|
||||
|
@ -123,7 +127,8 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
* <p>Removes elements that were selected by the filter
|
||||
* @see Collection#removeIf(Predicate)
|
||||
* @param filter Filters the elements that should be removed
|
||||
* @throws NullPointerException if filter is null
|
||||
* @return true if the collection was modified
|
||||
* @throws java.lang.NullPointerException if filter is null
|
||||
*/
|
||||
public default boolean remIf(JAVA_PREDICATE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
|
|
@ -19,7 +19,7 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
|
|||
* Returns the next element in the iteration.
|
||||
*
|
||||
* @return the next element in the iteration
|
||||
* @throws NoSuchElementException if the iteration has no more elements
|
||||
* @throws java.util.NoSuchElementException if the iteration has no more elements
|
||||
* @see Iterator#next()
|
||||
*/
|
||||
public KEY_TYPE NEXT();
|
||||
|
@ -45,7 +45,7 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
|
|||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
* @see Iterator#forEachRemaining(Consumer)
|
||||
*/
|
||||
public default void forEachRemaining(CONSUMER action) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||
|
||||
/**
|
||||
* The IndexOf implementation iterates over all elements and compares them to the search value.
|
||||
* @param e the value that the index is searched for.
|
||||
* @param o the value that the index is searched for.
|
||||
* @return index of the value that was searched for. -1 if not found
|
||||
* @deprecated it is highly suggested not to use this with Primitives because of boxing. But it is still supported because of ObjectComparason that are custom objects and allow to find the contents.
|
||||
*/
|
||||
|
@ -89,7 +89,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||
|
||||
/**
|
||||
* The lastIndexOf implementation iterates over all elements and compares them to the search value.
|
||||
* @param e the value that the index is searched for.
|
||||
* @param o the value that the index is searched for.
|
||||
* @return the last index of the value that was searched for. -1 if not found
|
||||
* @deprecated it is highly suggested not to use this with Primitives because of boxing. But it is still supported because of ObjectComparason that are custom objects and allow to find the contents.
|
||||
*/
|
||||
|
|
|
@ -126,13 +126,18 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
/**
|
||||
* Creates a wrapped arraylist that uses the array as backing array
|
||||
* @param a elements that should be wrapped
|
||||
* @return a Wrapped list using the input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) {
|
||||
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE wrap(KEY_TYPE... a) {
|
||||
return wrap(a, a.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wrapped arraylist that uses the array as backing array and a custom fillsize
|
||||
* @param a elements that should be wrapped
|
||||
* @param length the size of the elements within the array
|
||||
* @return a Wrapped list using the input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int length) {
|
||||
SanityChecks.checkArrayCapacity(a.length, 0, length);
|
||||
|
@ -145,6 +150,8 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
#if TYPE_OBJECT
|
||||
/**
|
||||
* Creates a new ArrayList with a EmptyObject array of the Type requested
|
||||
* @param c the type of the array
|
||||
* @return a typed List
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) {
|
||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||
|
@ -194,7 +201,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
* Appends the specified elements to the index of the list.
|
||||
* This function may delegate to more appropiate function if nessesary
|
||||
* @param index the index where to append the elements to
|
||||
* @param e the elements to append to the list
|
||||
* @param c the elements to append to the list
|
||||
* @throws IndexOutOfBoundsException if index is outside of the lists range
|
||||
* @deprecated if type is primitive
|
||||
*/
|
||||
|
@ -216,7 +223,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
* Appends the specified elements to the index of the list.
|
||||
* This function may delegate to more appropiate function if nessesary
|
||||
* @param index the index where to append the elements to
|
||||
* @param e the elements to append to the list
|
||||
* @param c the elements to append to the list
|
||||
* @throws IndexOutOfBoundsException if index is outside of the lists range
|
||||
* @deprecated if type is primitive
|
||||
*/
|
||||
|
@ -236,7 +243,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
/**
|
||||
* Appends the specified elements to the index of the list.
|
||||
* @param index the index where to append the elements to
|
||||
* @param e the elements to append to the list
|
||||
* @param c the elements to append to the list
|
||||
* @throws IndexOutOfBoundsException if index is outside of the lists range
|
||||
* @deprecated if type is primitive
|
||||
*/
|
||||
|
@ -277,7 +284,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
* @param a the array where the values should be inserted to
|
||||
* @param offset the startIndex of where the array should be written to
|
||||
* @param length the number of elements the values should be fetched from
|
||||
* @returns the inputArray
|
||||
* @return the inputArray
|
||||
* @throws NullPointerException if the array is null
|
||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||
* @throws IllegalStateException if offset or length are smaller then 0 or exceed the array length
|
||||
|
@ -353,7 +360,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
/**
|
||||
* A function to find if the Element is present in this list.
|
||||
* @param e the element that is searched for
|
||||
* @param o the element that is searched for
|
||||
* @return if the element was found.
|
||||
* @deprecated if type-specific but still supported because of special edgecase Object-Comparason features
|
||||
*/
|
||||
|
@ -365,7 +372,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
/**
|
||||
* A function to find the index of a given element
|
||||
* @param e the element that is searched for
|
||||
* @param o the element that is searched for
|
||||
* @return the index of the element if found. (if not found then -1)
|
||||
* @deprecated if type-specific but still supported because of special edgecase Object-Comparason features
|
||||
*/
|
||||
|
@ -389,7 +396,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
/**
|
||||
* A function to find the last index of a given element
|
||||
* @param e the element that is searched for
|
||||
* @param o the element that is searched for
|
||||
* @return the last index of the element if found. (if not found then -1)
|
||||
* @deprecated if type-specific but still supported because of special edgecase Object-Comparason features
|
||||
*/
|
||||
|
@ -414,6 +421,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
#if TYPE_OBJECT
|
||||
/**
|
||||
* Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
||||
* @param c the sorter of the elements, can be null
|
||||
* @see List#sort(Comparator)
|
||||
* @see ARRAYS#stableSort(KEY_TYPE[], Comparator)
|
||||
*/
|
||||
|
@ -425,6 +433,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
/**
|
||||
* Sorts the elements specified by the Natural order either by using the Comparator or the elements using a unstable sort
|
||||
* @param c the sorter of the elements, can be null
|
||||
* @see List#sort(Comparator)
|
||||
* @see ARRAYS#unstableSort(KEY_TYPE[], Comparator)
|
||||
*/
|
||||
|
@ -437,8 +446,8 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
#else
|
||||
/**
|
||||
* A Type Specific implementation of the Collection#contains function.
|
||||
* @param the element that is searched for.
|
||||
* @returns if the element was found
|
||||
* @param e the element that is searched for.
|
||||
* @return if the element was found
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(KEY_TYPE e) {
|
||||
|
@ -473,8 +482,9 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
/**
|
||||
* Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
||||
* @param c the sorter of the elements, can be null
|
||||
* @see List#sort(Comparator)
|
||||
* @see ARRAYS#stableSort(KEY_TYPE[], Comparator)
|
||||
* @see ARRAYS#stableSort(KEY_TYPE[], COMPARATOR)
|
||||
*/
|
||||
@Override
|
||||
public void sort(COMPARATOR c) {
|
||||
|
@ -484,8 +494,9 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
/**
|
||||
* Sorts the elements specified by the Natural order either by using the Comparator or the elements using a unstable sort
|
||||
* @param c the sorter of the elements, can be null
|
||||
* @see List#sort(Comparator)
|
||||
* @see ARRAYS#unstableSort(KEY_TYPE[], Comparator)
|
||||
* @see ARRAYS#unstableSort(KEY_TYPE[], COMPARATOR)
|
||||
*/
|
||||
@Override
|
||||
public void unstableSort(COMPARATOR c) {
|
||||
|
@ -541,7 +552,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @throws java.util.NullPointerException if the specified action is null
|
||||
* @see Iterable#forEach(Consumer)
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -46,7 +46,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
* @param c the elements that need to be added
|
||||
* @param index index at which the specified elements is to be inserted
|
||||
* @return true if the list was modified
|
||||
* @see List#addAll(int, Object)
|
||||
* @see java.util.List#addAll(int, Collection)
|
||||
*/
|
||||
public boolean addAll(int index, COLLECTION KEY_GENERIC_TYPE c);
|
||||
|
||||
|
@ -78,7 +78,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
/**
|
||||
* A Type-Specific set function to reduce (un)boxing
|
||||
* @param index index of the element to replace
|
||||
* @param element element to be stored at the specified position
|
||||
* @param e element to be stored at the specified position
|
||||
* @return the element previously at the specified position
|
||||
* @throws IndexOutOfBoundsException if the index is not within the list range
|
||||
* @see List#set(int, Object)
|
||||
|
@ -141,13 +141,20 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A function to fast add elements to the list
|
||||
* @param a the elements that should be added
|
||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||
*/
|
||||
public default void addElements(KEY_TYPE... a) { addElements(0, a, 0, a.length); }
|
||||
|
||||
/**
|
||||
* A function to fast add elements to the list
|
||||
* @param from the index where the elements should be added into the list
|
||||
* @param a the elements that should be added
|
||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||
*/
|
||||
public default void addElements(int from, KEY_TYPE[] a) { addElements(from, a, 0, a.length); }
|
||||
public default void addElements(int from, KEY_TYPE... a) { addElements(from, a, 0, a.length); }
|
||||
|
||||
/**
|
||||
* A function to fast add elements to the list
|
||||
|
@ -164,7 +171,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
* A function to fast fetch elements from the list
|
||||
* @param from index where the list should be fetching elements from
|
||||
* @param a the array where the values should be inserted to
|
||||
* @returns the inputArray
|
||||
* @return the inputArray
|
||||
* @throws NullPointerException if the array is null
|
||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||
* @throws IllegalStateException if offset or length are smaller then 0 or exceed the array length
|
||||
|
@ -177,7 +184,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
* @param a the array where the values should be inserted to
|
||||
* @param offset the startIndex of where the array should be written to
|
||||
* @param length the number of elements the values should be fetched from
|
||||
* @returns the inputArray
|
||||
* @return the inputArray
|
||||
* @throws NullPointerException if the array is null
|
||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||
* @throws IllegalStateException if offset or length are smaller then 0 or exceed the array length
|
||||
|
@ -255,8 +262,9 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
|
||||
/**
|
||||
* Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
||||
* @param c the sorter of the elements, can be null
|
||||
* @see List#sort(Comparator)
|
||||
* @see ARRAYS#stableSort(KEY_TYPE[], Comparator)
|
||||
* @see ARRAYS#stableSort(KEY_TYPE[], COMPARATOR)
|
||||
*/
|
||||
public default void sort(COMPARATOR c) {
|
||||
KEY_TYPE[] array = TO_ARRAY();
|
||||
|
@ -280,8 +288,9 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
|
||||
/**
|
||||
* Sorts the elements specified by the Natural order either by using the Comparator or the elements using a unstable sort
|
||||
* @param c the sorter of the elements, can be null
|
||||
* @see List#sort(Comparator)
|
||||
* @see ARRAYS#unstableSort(KEY_TYPE[], Comparator)
|
||||
* @see ARRAYS#unstableSort(KEY_TYPE[], COMPARATOR)
|
||||
*/
|
||||
public default void unstableSort(COMPARATOR c) {
|
||||
KEY_TYPE[] array = TO_ARRAY();
|
||||
|
|
|
@ -92,7 +92,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
|
||||
@Override
|
||||
public boolean replace(KEY_TYPE key, VALUE_TYPE oldValue, VALUE_TYPE newValue) {
|
||||
VALUE_TYPE curValue = get(key);
|
||||
VALUE_TYPE curValue = GET_VALUE(key);
|
||||
if (VALUE_EQUALS_NOT(curValue, oldValue) || (VALUE_EQUALS(curValue, getDefaultReturnValue()) && !containsKey(key))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public VALUE_TYPE replace(KEY_TYPE key, VALUE_TYPE value) {
|
||||
VALUE_TYPE curValue;
|
||||
if (VALUE_EQUALS_NOT((curValue = get(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
if (VALUE_EQUALS_NOT((curValue = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
curValue = put(key, value);
|
||||
}
|
||||
return curValue;
|
||||
|
@ -121,7 +121,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value = get(key);
|
||||
VALUE_TYPE value = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||
|
@ -138,7 +138,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if((value = get(key)) == getDefaultReturnValue()) {
|
||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
|
@ -152,7 +152,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if(VALUE_EQUALS_NOT((value = get(key)), getDefaultReturnValue())) {
|
||||
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
|
@ -166,7 +166,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE oldValue = get(key);
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? value : mappingFunction.APPLY_VALUE(oldValue, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
|
|
|
@ -105,6 +105,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
values[nullIndex] = value;
|
||||
containsNull = true;
|
||||
onNodeAdded(nullIndex);
|
||||
moveToFirstIndex(nullIndex);
|
||||
}
|
||||
else {
|
||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||
|
@ -120,6 +121,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
keys[pos] = key;
|
||||
values[pos] = value;
|
||||
onNodeAdded(pos);
|
||||
moveToFirstIndex(pos);
|
||||
}
|
||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||
return getDefaultReturnValue();
|
||||
|
@ -137,6 +139,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
values[nullIndex] = value;
|
||||
containsNull = true;
|
||||
onNodeAdded(nullIndex);
|
||||
moveToLastIndex(nullIndex);
|
||||
}
|
||||
else {
|
||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||
|
@ -152,6 +155,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
keys[pos] = key;
|
||||
values[pos] = value;
|
||||
onNodeAdded(pos);
|
||||
moveToLastIndex(pos);
|
||||
}
|
||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||
return getDefaultReturnValue();
|
||||
|
@ -305,7 +309,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
|
||||
@Override
|
||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||
if(values == null) valuesC = new Values();
|
||||
if(valuesC == null) valuesC = new Values();
|
||||
return valuesC;
|
||||
}
|
||||
|
||||
|
@ -425,8 +429,9 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||
VALUE_TYPE[] newValues = NEW_VALUE_ARRAY(newSize + 1);
|
||||
long[] newLinks = new long[newSize + 1];
|
||||
int newPrev = -1;
|
||||
for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) {
|
||||
int i = firstIndex, prev = -1, newPrev = -1, pos;
|
||||
firstIndex = -1;
|
||||
for(int j = size; j-- != 0;) {
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) pos = newSize;
|
||||
else {
|
||||
pos = HashUtil.mix(strategy.hashCode(keys[i])) & newMask;
|
||||
|
@ -452,6 +457,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
mask = newMask;
|
||||
maxFill = Math.min((int)Math.ceil(nullIndex * loadFactor), nullIndex - 1);
|
||||
keys = newKeys;
|
||||
values = newValues;
|
||||
}
|
||||
|
||||
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements SORTED_MAP.FastSortedSet KEY_VALUE_GENERIC_TYPE {
|
||||
|
@ -761,7 +767,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
MapEntry entry = new MapEntry(nextEntry());
|
||||
MapEntry entry = new MapEntry();
|
||||
|
||||
public FastEntryIterator() {}
|
||||
public FastEntryIterator(KEY_TYPE from) {
|
||||
|
|
|
@ -154,7 +154,11 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
@Override
|
||||
@Deprecated
|
||||
public boolean containsKey(Object key) {
|
||||
return findIndex(key) >= 0;
|
||||
#if !TYPE_OBJECT
|
||||
return key instanceof CLASS_TYPE && findIndex(CLASS_TO_KEY(key)) >= 0;
|
||||
#else
|
||||
return findIndex(CLASS_TO_KEY(key)) >= 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !VALUE_OBJECT
|
||||
|
@ -186,7 +190,10 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
@Override
|
||||
@Deprecated
|
||||
public CLASS_VALUE_TYPE remove(Object key) {
|
||||
int slot = findIndex(key);
|
||||
#if !TYPE_OBJECT
|
||||
if(!(key instanceof CLASS_TYPE)) return getDefaultReturnValue();
|
||||
#endif
|
||||
int slot = findIndex(CLASS_TO_KEY(key));
|
||||
if(slot < 0) return VALUE_TO_OBJ(getDefaultReturnValue());
|
||||
return removeIndex(slot);
|
||||
}
|
||||
|
@ -228,6 +235,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
}
|
||||
return false;
|
||||
}
|
||||
#if !TYPE_OBJECT
|
||||
if(!(key instanceof CLASS_TYPE)) return false;
|
||||
#endif
|
||||
KEY_TYPE keyType = CLASS_TO_KEY(key);
|
||||
int pos = HashUtil.mix(strategy.hashCode(keyType)) & mask;
|
||||
KEY_TYPE current = keys[pos];
|
||||
|
@ -253,14 +263,17 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE get(Object key) {
|
||||
int slot = findIndex(key);
|
||||
#if !TYPE_OBJECT
|
||||
if(!(key instanceof CLASS_TYPE)) return getDefaultReturnValue();
|
||||
#endif
|
||||
int slot = findIndex(CLASS_TO_KEY(key));
|
||||
return VALUE_TO_OBJ(slot < 0 ? getDefaultReturnValue() : values[slot]);
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
int slot = findIndex(key);
|
||||
int slot = findIndex(CLASS_TO_KEY(key));
|
||||
return slot < 0 ? defaultValue : values[slot];
|
||||
}
|
||||
|
||||
|
@ -299,6 +312,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() { return size; }
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if(size == 0) return;
|
||||
|
@ -322,7 +338,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
}
|
||||
|
||||
#endif
|
||||
protected int findIndex(Object key) {
|
||||
protected int findIndex(CLASS_TYPE key) {
|
||||
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||
KEY_TYPE keyType = CLASS_TO_KEY(key);
|
||||
int pos = HashUtil.mix(strategy.hashCode(keyType)) & mask;
|
||||
|
@ -645,14 +661,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
public void forEach(Consumer VALUE_SUPER_GENERIC_TYPE action) {
|
||||
if(containsNull) action.accept(values[nullIndex]);
|
||||
for(int i = nullIndex-1;i>=0;i--)
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i]);
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i]);
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
||||
if(containsNull) action.accept(values[nullIndex]);
|
||||
for(int i = nullIndex-1;i>=0;i--)
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i]);
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
values[nullIndex] = value;
|
||||
containsNull = true;
|
||||
onNodeAdded(nullIndex);
|
||||
moveToFirstIndex(nullIndex);
|
||||
}
|
||||
else {
|
||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||
|
@ -122,6 +123,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
keys[pos] = key;
|
||||
values[pos] = value;
|
||||
onNodeAdded(pos);
|
||||
moveToFirstIndex(pos);
|
||||
}
|
||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||
return getDefaultReturnValue();
|
||||
|
@ -139,6 +141,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
values[nullIndex] = value;
|
||||
containsNull = true;
|
||||
onNodeAdded(nullIndex);
|
||||
moveToLastIndex(nullIndex);
|
||||
}
|
||||
else {
|
||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||
|
@ -154,6 +157,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
keys[pos] = key;
|
||||
values[pos] = value;
|
||||
onNodeAdded(pos);
|
||||
moveToLastIndex(pos);
|
||||
}
|
||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||
return getDefaultReturnValue();
|
||||
|
@ -307,7 +311,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
|
||||
@Override
|
||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||
if(values == null) valuesC = new Values();
|
||||
if(valuesC == null) valuesC = new Values();
|
||||
return valuesC;
|
||||
}
|
||||
|
||||
|
@ -427,8 +431,9 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||
VALUE_TYPE[] newValues = NEW_VALUE_ARRAY(newSize + 1);
|
||||
long[] newLinks = new long[newSize + 1];
|
||||
int newPrev = -1;
|
||||
for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) {
|
||||
int i = firstIndex, prev = -1, newPrev = -1, pos;
|
||||
firstIndex = -1;
|
||||
for(int j = size; j-- != 0;) {
|
||||
if(KEY_EQUALS_NULL(keys[i])) pos = newSize;
|
||||
else {
|
||||
pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask;
|
||||
|
@ -454,6 +459,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
mask = newMask;
|
||||
maxFill = Math.min((int)Math.ceil(nullIndex * loadFactor), nullIndex - 1);
|
||||
keys = newKeys;
|
||||
values = newValues;
|
||||
}
|
||||
|
||||
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements SORTED_MAP.FastSortedSet KEY_VALUE_GENERIC_TYPE {
|
||||
|
@ -763,7 +769,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
}
|
||||
|
||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
MapEntry entry = new MapEntry(nextEntry());
|
||||
MapEntry entry = new MapEntry();
|
||||
|
||||
public FastEntryIterator() {}
|
||||
public FastEntryIterator(KEY_TYPE from) {
|
||||
|
|
|
@ -295,6 +295,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() { return size; }
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if(size == 0) return;
|
||||
|
|
|
@ -12,6 +12,7 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||
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;
|
||||
|
@ -19,6 +20,7 @@ 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;
|
||||
import speiger.src.collections.PACKAGE.sets.SET;
|
||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||
|
@ -26,6 +28,9 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
|||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
||||
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
||||
#endif
|
||||
#if !VALUE_OBJECT
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||
|
@ -33,6 +38,7 @@ import speiger.src.collections.objects.sets.AbstractObjectSet;
|
|||
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
||||
import speiger.src.collections.objects.sets.ObjectSet;
|
||||
#endif
|
||||
import speiger.src.collections.utils.HashUtil;
|
||||
|
||||
public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE implements SORTED_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
|
@ -43,6 +49,57 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
protected VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||
protected FastSortedSet KEY_VALUE_GENERIC_TYPE entrySet;
|
||||
|
||||
public ARRAY_MAP() {
|
||||
this(HashUtil.DEFAULT_MIN_CAPACITY);
|
||||
}
|
||||
|
||||
public ARRAY_MAP(int minCapacity) {
|
||||
if(minCapacity < 0) throw new IllegalStateException("Minimum Capacity is negative. This is not allowed");
|
||||
keys = NEW_KEY_ARRAY(minCapacity);
|
||||
values = NEW_VALUE_ARRAY(minCapacity);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||
public ARRAY_MAP(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values) {
|
||||
this(keys, values, keys.length);
|
||||
}
|
||||
|
||||
public ARRAY_MAP(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values, int length) {
|
||||
this(length);
|
||||
if(keys.length != values.length) throw new IllegalStateException("Input Arrays are not equal size");
|
||||
size = length;
|
||||
for(int i = 0,m=length;i<m;i++) {
|
||||
this.keys[i] = OBJ_TO_KEY(keys[i]);
|
||||
this.values[i] = OBJ_TO_VALUE(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
public ARRAY_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
||||
this(keys, values, keys.length);
|
||||
}
|
||||
|
||||
public ARRAY_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values, int length) {
|
||||
if(keys.length != values.length) throw new IllegalStateException("Input Arrays are not equal size");
|
||||
this.keys = Arrays.copyOf(keys, length);
|
||||
this.values = Arrays.copyOf(values, length);
|
||||
this.size = length;
|
||||
}
|
||||
|
||||
public ARRAY_MAP(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map) {
|
||||
this(map.size());
|
||||
putAll(map);
|
||||
}
|
||||
|
||||
public ARRAY_MAP(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
this(map.size());
|
||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(map);iter.hasNext();size++) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||
keys[size] = entry.ENTRY_KEY();
|
||||
values[size] = entry.ENTRY_VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value) {
|
||||
int index = findIndex(key);
|
||||
|
@ -106,7 +163,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) {
|
||||
int index = findIndex(key);
|
||||
if(index >= 0) {
|
||||
if(index > 0) {
|
||||
moveIndexToFirst(index);
|
||||
return true;
|
||||
}
|
||||
|
@ -116,7 +173,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) {
|
||||
int index = findIndex(key);
|
||||
if(index >= 0) {
|
||||
if(index < size-1) {
|
||||
moveIndexToLast(index);
|
||||
return true;
|
||||
}
|
||||
|
@ -205,13 +262,13 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
@Override
|
||||
public VALUE_TYPE FIRST_ENTRY_VALUE() {
|
||||
if(size <= 0) throw new NoSuchElementException();
|
||||
return values[size-1];
|
||||
return values[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE LAST_ENTRY_VALUE() {
|
||||
if(size <= 0) throw new NoSuchElementException();
|
||||
return values[0];
|
||||
return values[size-1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -266,6 +323,13 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
||||
if(size() <= 0) return;
|
||||
for(int i = 0;i<size;i++)
|
||||
action.accept(keys[i], values[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SET KEY_GENERIC_TYPE keySet() {
|
||||
if(keySet == null) keySet = new KeySet();
|
||||
|
@ -518,7 +582,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) {
|
||||
int index = findIndex(key);
|
||||
if(index >= 0) {
|
||||
if(index > 0) {
|
||||
moveIndexToFirst(index);
|
||||
return true;
|
||||
}
|
||||
|
@ -528,7 +592,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) {
|
||||
int index = findIndex(key);
|
||||
if(index >= 0) {
|
||||
if(index < size()-1) {
|
||||
moveIndexToLast(index);
|
||||
return true;
|
||||
}
|
||||
|
@ -650,6 +714,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
if(index < 0) return getDefaultReturnValue();
|
||||
VALUE_TYPE value = values[index];
|
||||
removeIndex(index);
|
||||
length--;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -659,6 +724,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
int index = findIndex(key, value);
|
||||
if(index < 0) return false;
|
||||
removeIndex(index);
|
||||
length--;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -669,6 +735,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
if(index < 0) return VALUE_TO_OBJ(getDefaultReturnValue());
|
||||
VALUE_TYPE value = values[index];
|
||||
removeIndex(index);
|
||||
length--;
|
||||
return VALUE_TO_OBJ(value);
|
||||
}
|
||||
|
||||
|
@ -677,6 +744,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
int index = findIndex(key, value);
|
||||
if(index < 0) return false;
|
||||
removeIndex(index);
|
||||
length--;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -750,8 +818,8 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
if(index == length-1) return;
|
||||
KEY_TYPE key = keys[index];
|
||||
VALUE_TYPE value = values[index];
|
||||
System.arraycopy(keys, offset+index+1, keys, offset+index, length-index-1);
|
||||
System.arraycopy(values, offset+index+1, values, offset+index, length-index-1);
|
||||
System.arraycopy(keys, index+1, keys, index, end()-index-1);
|
||||
System.arraycopy(values, index+1, values, index, end()-index-1);
|
||||
keys[end()-1] = key;
|
||||
values[end()-1] = value;
|
||||
}
|
||||
|
@ -767,7 +835,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
#if !TYPE_OBJECT
|
||||
protected int findIndex(KEY_TYPE key) {
|
||||
for(int i = length-1;i>=0;i--)
|
||||
if(KEY_EQUALS(keys[offset+i], key)) return i;
|
||||
if(KEY_EQUALS(keys[offset+i], key)) return i+offset;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -775,7 +843,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
#if !VALUE_OBJECT
|
||||
protected int findValue(VALUE_TYPE value) {
|
||||
for(int i = length-1;i>=0;i--)
|
||||
if(VALUE_EQUALS(values[offset+i], value)) return i;
|
||||
if(VALUE_EQUALS(values[offset+i], value)) return i+offset;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -783,21 +851,21 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
protected int findIndex(Object key, Object value) {
|
||||
if(key == null || value == null) return -1;
|
||||
for(int i = length-1;i>=0;i--)
|
||||
if(EQUALS_KEY_TYPE(keys[offset+i], key) && EQUALS_VALUE_TYPE(values[offset+i], value)) return i;
|
||||
if(EQUALS_KEY_TYPE(keys[offset+i], key) && EQUALS_VALUE_TYPE(values[offset+i], value)) return i+offset;
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected int findIndex(Object key) {
|
||||
if(key == null) return -1;
|
||||
for(int i = length-1;i>=0;i--)
|
||||
if(EQUALS_KEY_TYPE(keys[offset+i], key)) return i;
|
||||
if(EQUALS_KEY_TYPE(keys[offset+i], key)) return i+offset;
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected int findValue(Object value) {
|
||||
if(value == null) return -1;
|
||||
for(int i = length-1;i>=0;i--)
|
||||
if(EQUALS_VALUE_TYPE(values[offset+i], value)) return i;
|
||||
if(EQUALS_VALUE_TYPE(values[offset+i], value)) return i+offset;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1371,13 +1439,13 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
#if TYPE_OBJECT
|
||||
@Override
|
||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||
for(int i = 0;i<size;action.accept(keys[i]));
|
||||
for(int i = 0;i<size;action.accept(keys[i++]));
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_GENERIC_TYPE action) {
|
||||
for(int i = 0;i<size;action.accept(keys[i]));
|
||||
for(int i = 0;i<size;action.accept(keys[i++]));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1428,12 +1496,12 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
#if VALUE_OBJECT
|
||||
@Override
|
||||
public void forEach(Consumer<? super CLASS_VALUE_TYPE> action) {
|
||||
for(int i = 0;i<size;action.accept(values[i]));
|
||||
for(int i = 0;i<size;action.accept(values[i++]));
|
||||
}
|
||||
#else
|
||||
@Override
|
||||
public void forEach(VALUE_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||
for(int i = 0;i<size;action.accept(values[i]));
|
||||
for(int i = 0;i<size;action.accept(values[i++]));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import speiger.src.collections.objects.maps.abstracts.ABSTRACT_MAP;
|
|||
import speiger.src.collections.objects.maps.interfaces.MAP;
|
||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||
import speiger.src.collections.objects.sets.ObjectSet;
|
||||
//import sun.misc.SharedSecrets;
|
||||
import sun.misc.SharedSecrets;
|
||||
|
||||
public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
|
@ -183,8 +183,8 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
}
|
||||
protected boolean isSet(int index) { return (present[index >> 6] & (1L << index)) != 0; }
|
||||
private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) {
|
||||
return keyType.getEnumConstants();
|
||||
// return SharedSecrets.getJavaLangAccess().getEnumConstantsShared(keyType);
|
||||
// return keyType.getEnumConstants();
|
||||
return SharedSecrets.getJavaLangAccess().getEnumConstantsShared(keyType);
|
||||
}
|
||||
|
||||
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
|
@ -58,6 +58,54 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
protected NAVIGABLE_SET KEY_GENERIC_TYPE keySet;
|
||||
protected VALUE_COLLECTION VALUE_GENERIC_TYPE values;
|
||||
protected ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
||||
|
||||
public AVL_TREE_MAP() {
|
||||
}
|
||||
|
||||
public AVL_TREE_MAP(COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||
public AVL_TREE_MAP(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values) {
|
||||
this(keys, values, null);
|
||||
}
|
||||
|
||||
public AVL_TREE_MAP(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
if(keys.length != values.length) throw new IllegalStateException("Input Arrays are not equal size");
|
||||
for(int i = 0,m=keys.length;i<m;i++) put(OBJ_TO_KEY(keys[i]), OBJ_TO_VALUE(values[i]));
|
||||
}
|
||||
|
||||
#endif
|
||||
public AVL_TREE_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
||||
this(keys, values, null);
|
||||
}
|
||||
|
||||
public AVL_TREE_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
if(keys.length != values.length) throw new IllegalStateException("Input Arrays are not equal size");
|
||||
for(int i = 0,m=keys.length;i<m;i++) put(keys[i], values[i]);
|
||||
}
|
||||
|
||||
public AVL_TREE_MAP(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map) {
|
||||
this(map, null);
|
||||
}
|
||||
|
||||
public AVL_TREE_MAP(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
putAll(map);
|
||||
}
|
||||
|
||||
public AVL_TREE_MAP(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
this(map, null);
|
||||
}
|
||||
|
||||
public AVL_TREE_MAP(MAP KEY_VALUE_GENERIC_TYPE map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
putAll(map);
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public KEY_TYPE getDefaultMaxValue() { return defaultMaxNotFound; }
|
||||
public KEY_TYPE getDefaultMinValue() { return defaultMinNotFound; }
|
||||
|
@ -324,6 +372,17 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public int size() { return size; }
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
size = 0;
|
||||
first = null;
|
||||
last = null;
|
||||
tree = null;
|
||||
}
|
||||
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending) {
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = new KeyIterator(descending);
|
||||
return descending ? ITERATORS.invert(iter) : iter;
|
||||
|
@ -567,7 +626,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
|
||||
protected int compare(KEY_TYPE k, KEY_TYPE v) { return comparator != null ? comparator.compare(k, v) : COMPAREABLE_TO_KEY(k, v);}
|
||||
|
||||
/** From CLR */
|
||||
protected void rotateLeft(Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(entry != null) {
|
||||
Entry KEY_VALUE_GENERIC_TYPE right = entry.right;
|
||||
|
@ -582,7 +640,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
}
|
||||
|
||||
/** From CLR */
|
||||
protected void rotateRight(Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(entry != null) {
|
||||
Entry KEY_VALUE_GENERIC_TYPE left = entry.left;
|
||||
|
@ -597,7 +654,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
}
|
||||
|
||||
/** From CLR */
|
||||
protected void fixAfterInsertion(Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
while(entry != null) {
|
||||
entry.updateHeight();
|
||||
|
@ -622,7 +678,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
}
|
||||
|
||||
/** From CLR */
|
||||
protected void fixAfterDeletion(Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(entry != null) {
|
||||
entry.updateHeight();
|
||||
|
@ -697,7 +752,61 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public DescendingSubMap(AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
super(m, fromStart, low, loInclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public KEY_TYPE FIRST_ENTRY_KEY() { return super.LAST_ENTRY_KEY(); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { return super.POLL_LAST_ENTRY_KEY(); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE LAST_ENTRY_KEY() { return super.FIRST_ENTRY_KEY(); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() { return super.POLL_FIRST_ENTRY_KEY(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { return super.LAST_ENTRY_VALUE(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return super.FIRST_ENTRY_VALUE(); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { return super.lastEntry(); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { return super.firstEntry(); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() { return super.pollLastEntry(); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() { return super.pollFirstEntry(); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE lowerKey(KEY_TYPE e) { return super.higherKey(e); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE floorKey(KEY_TYPE e) { return super.ceilingKey(e); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE ceilingKey(KEY_TYPE e) { return super.floorKey(e); }
|
||||
|
||||
@Override
|
||||
public KEY_TYPE higherKey(KEY_TYPE e) { return super.lowerKey(e); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lowerEntry(KEY_TYPE e) { return super.higherEntry(e); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE e) { return super.ceilingEntry(e); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE e) { return super.floorEntry(e); }
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE higherEntry(KEY_TYPE e) { return super.lowerEntry(e); }
|
||||
|
||||
@Override
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending) {
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = new SubMapKeyIterator(!descending);
|
||||
|
@ -711,7 +820,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator().reversed(); }
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator() == null ? null : m.comparator().reversed(); }
|
||||
|
||||
@Override
|
||||
VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator() { return VALUE_ITERATORS.invert(new SubMapValueIterator(true)); }
|
||||
|
@ -933,7 +1042,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
#endif
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
|
||||
return inRange(key) ? m.remove(key) : getDefaultReturnValue();
|
||||
return inRange(key) ? m.REMOVE_KEY(key) : getDefaultReturnValue();
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
|
|
|
@ -58,6 +58,54 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
protected NAVIGABLE_SET KEY_GENERIC_TYPE keySet;
|
||||
protected VALUE_COLLECTION VALUE_GENERIC_TYPE values;
|
||||
protected ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
||||
|
||||
public RB_TREE_MAP() {
|
||||
}
|
||||
|
||||
public RB_TREE_MAP(COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||
public RB_TREE_MAP(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values) {
|
||||
this(keys, values, null);
|
||||
}
|
||||
|
||||
public RB_TREE_MAP(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
if(keys.length != values.length) throw new IllegalStateException("Input Arrays are not equal size");
|
||||
for(int i = 0,m=keys.length;i<m;i++) put(OBJ_TO_KEY(keys[i]), OBJ_TO_VALUE(values[i]));
|
||||
}
|
||||
|
||||
#endif
|
||||
public RB_TREE_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
||||
this(keys, values, null);
|
||||
}
|
||||
|
||||
public RB_TREE_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
if(keys.length != values.length) throw new IllegalStateException("Input Arrays are not equal size");
|
||||
for(int i = 0,m=keys.length;i<m;i++) put(keys[i], values[i]);
|
||||
}
|
||||
|
||||
public RB_TREE_MAP(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map) {
|
||||
this(map, null);
|
||||
}
|
||||
|
||||
public RB_TREE_MAP(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
putAll(map);
|
||||
}
|
||||
|
||||
public RB_TREE_MAP(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||
this(map, null);
|
||||
}
|
||||
|
||||
public RB_TREE_MAP(MAP KEY_VALUE_GENERIC_TYPE map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
putAll(map);
|
||||
}
|
||||
|
||||