Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36f24731b0 | ||
|
|
ea5ace0166 | ||
|
|
663809ff27 | ||
|
|
5d6adb5446 | ||
|
|
212ad1ace2 | ||
|
|
707827929a | ||
|
|
27ad01657d | ||
|
|
e7da7acc08 | ||
|
|
72943cb22c | ||
|
|
068cc4a4f7 | ||
|
|
31b34f5de1 | ||
|
|
4bded1af80 | ||
|
|
100c7fe260 |
@@ -32,7 +32,5 @@ jobs:
|
||||
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: Generate SourceCode with Gradle
|
||||
run: ./gradlew generateGithubSource
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# Changelog of versions
|
||||
|
||||
### Version 0.6.2
|
||||
- Added: Array only sorting function return the inputed array. This was done to allow for static final references to use the method in one go without having to make lambda wrappers. Cleaner code.
|
||||
- Added: Iterator Wrappers are now a bit more in Compliance with Java Standards.
|
||||
- Added: AsyncBuilders now Support Array Inputs to create cleaner code.
|
||||
- Changed: LinkedList.addBulk variable definition was triggering a false positive.
|
||||
- Fixed: TreeMap.subMap().entrySet().remove() wouldn't check primitives properly.
|
||||
- Fixed: SortedMap.sub/tail/headMap were looping into themselves.
|
||||
- Fixed: AbstractCollection.retainAll didn't push removed values through the consumer.
|
||||
- Fixed: AbstractCollection.toArray wouldn't reset the last entry if the input array was larger then the elements in the collection.
|
||||
- Fixed: SubList didn't check for ranges properly or didn't use parent list to validate changes.
|
||||
- Fixed: ArrayList.addElements didn't check input array fully and used the wrong variable to move the elements around.
|
||||
- Fixed: LinkedList.addElements(EmptyInput) would crash.
|
||||
- Fixed: LinkedList.swapRemove didn't account for if the removed element was the prelast one.
|
||||
- Fixed: LinkedList.removeElements would break the implementation if the list was almost empty and the middle element was removed.
|
||||
- Fixed: LinkedHashSet.addAndMoveToFirst wouldn't move elements to the first place.
|
||||
- Fixed: ArrayList/LinkedList extractElements crashing when 0 or less elements are desired.
|
||||
- Fixed: TreeMap pollFirst/LastKey should return the defaultMin/max value instead of a Empty value.
|
||||
- Fixed: TreeMap keySet implementation was missing the class type implementations to pass keySet tests.
|
||||
- Fixed: TreeMap.SubMap Iterator (primitive Keys) was crashing because a Null was set on to a primitive.
|
||||
|
||||
|
||||
### Version 0.6.1
|
||||
- Fixed: FIFO queue crashing when the last index is before the first index when peek is called.
|
||||
- Fixed: FIFO queue only clears the array if it was in use.
|
||||
|
||||
@@ -42,7 +42,7 @@ repositories {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation 'com.github.Speiger:Primitive-Collections:0.6.1'
|
||||
implementation 'com.github.Speiger:Primitive-Collections:0.6.2'
|
||||
}
|
||||
```
|
||||
Using Custom Gradle:
|
||||
@@ -53,7 +53,7 @@ repositories {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation 'de.speiger:Primitive-Collections:0.6.1'
|
||||
implementation 'de.speiger:Primitive-Collections:0.6.2'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -63,6 +63,7 @@ dependencies {
|
||||
|
||||
| Version | Jar | Sources | Java Doc |
|
||||
|--------- |------------------------------------------------------------------------------------------------------------------------------ |-------------------------------------------------------------------------------------------------------------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 0.6.2 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.2/Primitive-Collections-0.6.2.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.2/Primitive-Collections-0.6.2-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.2/Primitive-Collections-0.6.2-javadoc.jar) |
|
||||
| 0.6.1 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.1/Primitive-Collections-0.6.1.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.1/Primitive-Collections-0.6.1-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.1/Primitive-Collections-0.6.1-javadoc.jar) |
|
||||
| 0.6.0 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.0/Primitive-Collections-0.6.0.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.0/Primitive-Collections-0.6.0-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.0/Primitive-Collections-0.6.0-javadoc.jar) |
|
||||
| 0.5.3 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.3/Primitive-Collections-0.5.3.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.3/Primitive-Collections-0.5.3-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.3/Primitive-Collections-0.5.3-javadoc.jar) |
|
||||
@@ -98,6 +99,5 @@ Please if you want to contribute follow the [Rule-Sheet](RuleSheet.md). It keeps
|
||||
The SourceCode can be generated via:
|
||||
/gradlew.bat generateSource
|
||||
|
||||
to build the jar:
|
||||
/gradlew.bat build
|
||||
do not combine the commands because they can not be executed at the same time.
|
||||
to generate SourceCode and build the jar:
|
||||
/gradlew.bat build
|
||||
+1
-1
@@ -18,7 +18,7 @@ repositories {
|
||||
}
|
||||
|
||||
archivesBaseName = 'Primitive Collections'
|
||||
version = '0.6.1';
|
||||
version = '0.6.2';
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||
|
||||
|
||||
@@ -2,6 +2,5 @@ jdk:
|
||||
- openjdk9
|
||||
install:
|
||||
- chmod +x ./gradlew
|
||||
- ./gradlew generateGithubSource
|
||||
- ./gradlew build publishToMavenLocal
|
||||
|
||||
|
||||
+2
@@ -230,6 +230,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||
KEY_TYPE e = iter.NEXT();
|
||||
if(!c.contains(e)) {
|
||||
r.accept(e);
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
@@ -256,6 +257,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||
if(a == null || a.length < size()) a = new KEY_TYPE[size()];
|
||||
ITERATORS.unwrap(a, iterator());
|
||||
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -315,7 +315,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
||||
public void removeElements(int from, int to) {
|
||||
if(to-from <= 0) return;
|
||||
checkSubRange(from);
|
||||
checkSubRange(to);
|
||||
checkAddSubRange(to);
|
||||
list.removeElements(from+parentOffset, to+parentOffset);
|
||||
size -= to - from;
|
||||
}
|
||||
@@ -324,9 +324,9 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
||||
@Override
|
||||
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
||||
checkSubRange(from);
|
||||
checkSubRange(to);
|
||||
checkAddSubRange(to);
|
||||
K[] result = list.extractElements(from+parentOffset, to+parentOffset, type);
|
||||
size -= to - from;
|
||||
size -= result.length;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -334,9 +334,9 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
||||
@Override
|
||||
public KEY_TYPE[] extractElements(int from, int to) {
|
||||
checkSubRange(from);
|
||||
checkSubRange(to);
|
||||
checkAddSubRange(to);
|
||||
KEY_TYPE[] result = list.extractElements(from+parentOffset, to+parentOffset);
|
||||
size -= to - from;
|
||||
size -= result.length;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -324,8 +324,9 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||
if(length <= 0) return;
|
||||
checkAddRange(from);
|
||||
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||
grow(size + length);
|
||||
if(from != size) System.arraycopy(data, from, data, from+length, size - length);
|
||||
if(from != size) System.arraycopy(data, from, data, from+length, size - from);
|
||||
size+=length;
|
||||
System.arraycopy(a, offset, data, from, length);
|
||||
}
|
||||
@@ -361,11 +362,11 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
int length = to - from;
|
||||
if(length <= 0) return;
|
||||
if(to != size) System.arraycopy(data, to, data, from, size - to);
|
||||
size -= length;
|
||||
#if TYPE_OBJECT
|
||||
for(int i = 0;i<length;i++)
|
||||
data[i+to] = null;
|
||||
data[i+size] = null;
|
||||
#endif
|
||||
size -= length;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
@@ -381,13 +382,13 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
checkRange(from);
|
||||
checkAddRange(to);
|
||||
int length = to - from;
|
||||
if(length <= 0) return ARRAYS.newArray(type, 0);
|
||||
K[] a = ARRAYS.newArray(type, length);
|
||||
if(length <= 0) return a;
|
||||
System.arraycopy(data, from, a, 0, length);
|
||||
if(to != size) System.arraycopy(data, to, data, from, size - to);
|
||||
size -= length;
|
||||
for(int i = 0;i<length;i++)
|
||||
data[i+to] = null;
|
||||
size -= length;
|
||||
data[i+size] = null;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -365,6 +365,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
||||
KEY_TYPE[] data = this.data;
|
||||
int size = data.length;
|
||||
if(from < 0 || from > size) throw new IndexOutOfBoundsException("Index: " + from + ", Size: " + size);
|
||||
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||
KEY_TYPE[] newElements;
|
||||
if(from == size) {
|
||||
newElements = Arrays.copyOf(data, size+length);
|
||||
@@ -1580,7 +1581,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
||||
lock.lock();
|
||||
try {
|
||||
checkSubRange(from);
|
||||
checkSubRange(to);
|
||||
checkAddSubRange(to);
|
||||
list.removeElements(from+parentOffset, to+parentOffset);
|
||||
size -= to - from;
|
||||
}
|
||||
@@ -1596,9 +1597,9 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
||||
lock.lock();
|
||||
try {
|
||||
checkSubRange(from);
|
||||
checkSubRange(to);
|
||||
checkAddSubRange(to);
|
||||
K[] result = list.extractElements(from+parentOffset, to+parentOffset, type);
|
||||
size -= to - from;
|
||||
size -= result.length;
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
@@ -1613,9 +1614,9 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
||||
lock.lock();
|
||||
try {
|
||||
checkSubRange(from);
|
||||
checkSubRange(to);
|
||||
checkAddSubRange(to);
|
||||
KEY_TYPE[] result = list.extractElements(from+parentOffset, to+parentOffset);
|
||||
size -= to - from;
|
||||
size -= result.length;
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
|
||||
+80
-45
@@ -152,10 +152,16 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
int length = c.size();
|
||||
if(length == 0) return false;
|
||||
checkAddRange(index);
|
||||
Entry KEY_GENERIC_TYPE next = null;
|
||||
Entry KEY_GENERIC_TYPE prev = null;
|
||||
if(index == size) prev = last;
|
||||
else if(index == 0) next = first;
|
||||
Entry KEY_GENERIC_TYPE next;
|
||||
Entry KEY_GENERIC_TYPE prev;
|
||||
if(index == size) {
|
||||
prev = last;
|
||||
next = null;
|
||||
}
|
||||
else if(index == 0) {
|
||||
next = first;
|
||||
prev = null;
|
||||
}
|
||||
else {
|
||||
next = getNode(index);
|
||||
prev = next.prev;
|
||||
@@ -180,10 +186,16 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
int length = c.size();
|
||||
if(length == 0) return false;
|
||||
checkAddRange(index);
|
||||
Entry KEY_GENERIC_TYPE next = null;
|
||||
Entry KEY_GENERIC_TYPE prev = null;
|
||||
if(index == size) prev = last;
|
||||
else if(index == 0) next = first;
|
||||
Entry KEY_GENERIC_TYPE next;
|
||||
Entry KEY_GENERIC_TYPE prev;
|
||||
if(index == size) {
|
||||
prev = last;
|
||||
next = null;
|
||||
}
|
||||
else if(index == 0) {
|
||||
next = first;
|
||||
prev = null;
|
||||
}
|
||||
else {
|
||||
next = getNode(index);
|
||||
prev = next.prev;
|
||||
@@ -210,10 +222,16 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
int length = c.size();
|
||||
if(length == 0) return false;
|
||||
checkAddRange(index);
|
||||
Entry KEY_GENERIC_TYPE next = null;
|
||||
Entry KEY_GENERIC_TYPE prev = null;
|
||||
if(index == size) prev = last;
|
||||
else if(index == 0) next = first;
|
||||
Entry KEY_GENERIC_TYPE next;
|
||||
Entry KEY_GENERIC_TYPE prev;
|
||||
if(index == size) {
|
||||
prev = last;
|
||||
next = null;
|
||||
}
|
||||
else if(index == 0) {
|
||||
next = first;
|
||||
prev = null;
|
||||
}
|
||||
else {
|
||||
next = getNode(index);
|
||||
prev = next.prev;
|
||||
@@ -258,12 +276,19 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
|
||||
@Override
|
||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||
if(length <= 0) return;
|
||||
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||
checkAddRange(from);
|
||||
Entry KEY_GENERIC_TYPE next = null;
|
||||
Entry KEY_GENERIC_TYPE prev = null;
|
||||
if(from == size) prev = last;
|
||||
else if(from == 0) next = first;
|
||||
Entry KEY_GENERIC_TYPE next;
|
||||
Entry KEY_GENERIC_TYPE prev;
|
||||
if(from == size) {
|
||||
prev = last;
|
||||
next = null;
|
||||
}
|
||||
else if(from == 0) {
|
||||
next = first;
|
||||
prev = null;
|
||||
}
|
||||
else {
|
||||
next = getNode(from);
|
||||
prev = next.prev;
|
||||
@@ -593,12 +618,14 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
first = temp;
|
||||
return result;
|
||||
}
|
||||
Entry KEY_GENERIC_TYPE temp = last;
|
||||
last = temp.prev;
|
||||
last.next = null;
|
||||
temp.next = before.next;
|
||||
temp.prev = before;
|
||||
before.next = temp;
|
||||
else if(before.next != last) {
|
||||
Entry KEY_GENERIC_TYPE temp = last;
|
||||
last = temp.prev;
|
||||
last.next = null;
|
||||
temp.next = before.next;
|
||||
temp.prev = before;
|
||||
before.next = temp;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -623,12 +650,14 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
first = temp;
|
||||
return true;
|
||||
}
|
||||
Entry KEY_GENERIC_TYPE temp = last;
|
||||
last = temp.prev;
|
||||
last.next = null;
|
||||
temp.next = before.next;
|
||||
temp.prev = before;
|
||||
before.next = temp;
|
||||
else if(before.next != last) {
|
||||
Entry KEY_GENERIC_TYPE temp = last;
|
||||
last = temp.prev;
|
||||
last.next = null;
|
||||
temp.next = before.next;
|
||||
temp.prev = before;
|
||||
before.next = temp;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -671,16 +700,18 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
if(from < size - to) {
|
||||
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
||||
while(length > 0) {
|
||||
entry = entry.next;
|
||||
unlink(entry.prev);
|
||||
Entry KEY_GENERIC_TYPE next = entry.next;
|
||||
unlink(entry);
|
||||
entry = next;
|
||||
length--;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Entry KEY_GENERIC_TYPE entry = getNode(to);
|
||||
while(length > 0) {
|
||||
entry = entry.prev;
|
||||
unlink(entry.next);
|
||||
Entry KEY_GENERIC_TYPE prev = entry.prev;
|
||||
unlink(entry);
|
||||
entry = prev;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
@@ -691,20 +722,22 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
checkRange(from);
|
||||
checkAddRange(to);
|
||||
int length = to - from;
|
||||
if(length <= 0) return ARRAYS.newArray(type, 0);
|
||||
K[] a = ARRAYS.newArray(type, length);
|
||||
if(length <= 0) return a;
|
||||
if(from < size - to) {
|
||||
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
||||
for(int i = 0;length > 0;i++, length--) {
|
||||
entry = entry.next;
|
||||
a[i] = (K)unlink(entry.prev);
|
||||
Entry KEY_GENERIC_TYPE next = entry.next;
|
||||
a[i] = (K)unlink(entry);
|
||||
entry = next;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
Entry KEY_GENERIC_TYPE entry = getNode(to);
|
||||
for(int i = length-1;length > 0;i--) {
|
||||
entry = entry.prev;
|
||||
a[i] = (K)unlink(entry.next);
|
||||
for(int i = length-1;length > 0;i--, length--) {
|
||||
Entry KEY_GENERIC_TYPE prev = entry.prev;
|
||||
a[i] = (K)unlink(entry);
|
||||
entry = prev;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
@@ -720,15 +753,17 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
if(from < size - to) {
|
||||
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
||||
for(int i = 0;length > 0;i++, length--) {
|
||||
entry = entry.next;
|
||||
d[i] = unlink(entry.prev);
|
||||
Entry KEY_GENERIC_TYPE next = entry.next;
|
||||
d[i] = unlink(entry);
|
||||
entry = next;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
Entry KEY_GENERIC_TYPE entry = getNode(to);
|
||||
for(int i = length-1;length > 0;i--) {
|
||||
entry = entry.prev;
|
||||
d[i] = unlink(entry.next);
|
||||
for(int i = length-1;length > 0;i--, length--) {
|
||||
Entry KEY_GENERIC_TYPE prev = entry.prev;
|
||||
d[i] = unlink(entry);
|
||||
entry = prev;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
@@ -1239,7 +1274,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
return list.size - index;
|
||||
return (long)list.size - (long)index;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1305,7 +1340,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
return list.size - index;
|
||||
return (long)list.size - (long)index;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+37
-10
@@ -408,7 +408,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
||||
if(tree == null) return EMPTY_KEY_VALUE;
|
||||
if(tree == null) return getDefaultMinValue();
|
||||
KEY_TYPE result = first.key;
|
||||
removeNode(first);
|
||||
return result;
|
||||
@@ -422,7 +422,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
||||
if(tree == null) return EMPTY_KEY_VALUE;
|
||||
if(tree == null) return getDefaultMaxValue();
|
||||
KEY_TYPE result = last.key;
|
||||
removeNode(last);
|
||||
return result;
|
||||
@@ -1022,6 +1022,33 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
public KEY_TYPE ceiling(KEY_TYPE e) { return map.ceilingKey(e); }
|
||||
@Override
|
||||
public KEY_TYPE higher(KEY_TYPE e) { return map.higherKey(e); }
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public CLASS_TYPE lower(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.lowerEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE floor(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.floorEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE higher(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.higherEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE ceiling(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.ceilingEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
||||
@Override
|
||||
@@ -1461,8 +1488,8 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE element);
|
||||
protected abstract VALUE_BI_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE descendingKeyIterator();
|
||||
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
||||
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
||||
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMinValue() : entry.key; }
|
||||
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMaxValue() : entry.key; }
|
||||
protected Node KEY_VALUE_GENERIC_TYPE next(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.next(); }
|
||||
protected Node KEY_VALUE_GENERIC_TYPE previous(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.previous(); }
|
||||
|
||||
@@ -1533,7 +1560,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
map.removeNode(entry);
|
||||
return result;
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
return getDefaultMinValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1544,7 +1571,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
map.removeNode(entry);
|
||||
return result;
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
return getDefaultMaxValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1632,7 +1659,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
return inRange(key) ? map.REMOVE_VALUE(key) : defaultValue;
|
||||
return inRange(key) ? map.REMOVE_VALUEOrDefault(key, defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@@ -1778,7 +1805,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
if (!inRange(key)) return false;
|
||||
Node KEY_VALUE_GENERIC_TYPE node = map.findNode(key);
|
||||
if (node != null && VALUE_EQUALS(node.getValue(), entry.getValue())) {
|
||||
if (node != null && VALUE_EQUALS(node.ENTRY_VALUE(), entry.ENTRY_VALUE())) {
|
||||
map.removeNode(node);
|
||||
return true;
|
||||
}
|
||||
@@ -2147,8 +2174,8 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
public SubMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence)
|
||||
{
|
||||
next = first;
|
||||
this.forwardFence = forwardFence == null ? null : forwardFence.key;
|
||||
this.backwardFence = backwardFence == null ? null : backwardFence.key;
|
||||
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||
unboundForwardFence = forwardFence == null;
|
||||
unboundBackwardFence = backwardFence == null;
|
||||
}
|
||||
|
||||
+37
-10
@@ -411,7 +411,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
||||
if(tree == null) return EMPTY_KEY_VALUE;
|
||||
if(tree == null) return getDefaultMinValue();
|
||||
KEY_TYPE result = first.key;
|
||||
removeNode(first);
|
||||
return result;
|
||||
@@ -425,7 +425,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
|
||||
@Override
|
||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
||||
if(tree == null) return EMPTY_KEY_VALUE;
|
||||
if(tree == null) return getDefaultMaxValue();
|
||||
KEY_TYPE result = last.key;
|
||||
removeNode(last);
|
||||
return result;
|
||||
@@ -1080,6 +1080,33 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
public KEY_TYPE ceiling(KEY_TYPE e) { return map.ceilingKey(e); }
|
||||
@Override
|
||||
public KEY_TYPE higher(KEY_TYPE e) { return map.higherKey(e); }
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public CLASS_TYPE lower(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.lowerEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE floor(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.floorEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE higher(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.higherEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_TYPE ceiling(CLASS_TYPE e) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.ceilingEntry(OBJ_TO_KEY(e));
|
||||
return node != null ? node.getKey() : null;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE POLL_FIRST_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
||||
@Override
|
||||
@@ -1518,8 +1545,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE element);
|
||||
protected abstract VALUE_BI_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE descendingKeyIterator();
|
||||
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
||||
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
||||
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMinValue() : entry.key; }
|
||||
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMaxValue() : entry.key; }
|
||||
protected Node KEY_VALUE_GENERIC_TYPE next(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.next(); }
|
||||
protected Node KEY_VALUE_GENERIC_TYPE previous(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.previous(); }
|
||||
|
||||
@@ -1590,7 +1617,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
map.removeNode(entry);
|
||||
return result;
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
return getDefaultMinValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1601,7 +1628,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
map.removeNode(entry);
|
||||
return result;
|
||||
}
|
||||
return EMPTY_KEY_VALUE;
|
||||
return getDefaultMaxValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1689,7 +1716,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
return inRange(key) ? map.REMOVE_VALUE(key) : defaultValue;
|
||||
return inRange(key) ? map.REMOVE_VALUEOrDefault(key, defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@@ -1835,7 +1862,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
if (!inRange(key)) return false;
|
||||
Node KEY_VALUE_GENERIC_TYPE node = map.findNode(key);
|
||||
if (node != null && VALUE_EQUALS(node.getValue(), entry.getValue())) {
|
||||
if (node != null && VALUE_EQUALS(node.ENTRY_VALUE(), entry.ENTRY_VALUE())) {
|
||||
map.removeNode(node);
|
||||
return true;
|
||||
}
|
||||
@@ -2204,8 +2231,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
public SubMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence)
|
||||
{
|
||||
next = first;
|
||||
this.forwardFence = forwardFence == null ? null : forwardFence.key;
|
||||
this.backwardFence = backwardFence == null ? null : backwardFence.key;
|
||||
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||
unboundForwardFence = forwardFence == null;
|
||||
unboundBackwardFence = backwardFence == null;
|
||||
}
|
||||
|
||||
+3
-3
@@ -155,11 +155,11 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
||||
public VALUE_TYPE LAST_ENTRY_VALUE();
|
||||
|
||||
@Override
|
||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, CLASS_TYPE toKey) { return subMap(OBJ_TO_KEY(fromKey), OBJ_TO_KEY(toKey)); }
|
||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, CLASS_TYPE toKey);
|
||||
@Override
|
||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE headMap(CLASS_TYPE toKey) { return headMap(OBJ_TO_KEY(toKey)); }
|
||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE headMap(CLASS_TYPE toKey);
|
||||
@Override
|
||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(CLASS_TYPE fromKey) { return tailMap(OBJ_TO_KEY(fromKey)); }
|
||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(CLASS_TYPE fromKey);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -434,6 +434,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
KEY_TYPE value = array[index];
|
||||
removeIndex(index);
|
||||
index = ++index % array.length;
|
||||
|
||||
+2
-1
@@ -187,7 +187,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
||||
|
||||
@Override
|
||||
public void enqueue(KEY_TYPE e) {
|
||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (array.length >> 1), SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||
if(firstIndex != -1){
|
||||
int compare = comparator == null ? COMPAREABLE_TO_KEY(e, array[firstIndex]) : comparator.compare(e, array[firstIndex]);
|
||||
if(compare < 0) firstIndex = size;
|
||||
@@ -414,6 +414,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -207,7 +207,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
||||
|
||||
@Override
|
||||
public void enqueue(KEY_TYPE e) {
|
||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (array.length >> 1), SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||
array[size++] = e;
|
||||
ARRAYS.shiftUp(array, size-1, comparator);
|
||||
}
|
||||
@@ -389,6 +389,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -237,6 +237,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
||||
}
|
||||
containsNull = true;
|
||||
onNodeAdded(nullIndex);
|
||||
moveToFirstIndex(nullIndex);
|
||||
}
|
||||
else {
|
||||
int pos = HashUtil.mix(strategy.hashCode(o)) & mask;
|
||||
@@ -249,6 +250,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
||||
}
|
||||
keys[pos] = o;
|
||||
onNodeAdded(pos);
|
||||
moveToFirstIndex(pos);
|
||||
}
|
||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||
return true;
|
||||
|
||||
+2
@@ -208,6 +208,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
||||
}
|
||||
containsNull = true;
|
||||
onNodeAdded(nullIndex);
|
||||
moveToFirstIndex(nullIndex);
|
||||
}
|
||||
else {
|
||||
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||
@@ -220,6 +221,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
||||
}
|
||||
keys[pos] = o;
|
||||
onNodeAdded(pos);
|
||||
moveToFirstIndex(pos);
|
||||
}
|
||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||
return true;
|
||||
|
||||
@@ -348,9 +348,11 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @param comp the Comparator that decides the sorting order
|
||||
* @return input array.
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] stableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
stableSort(array, 0, array.length, comp);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,9 +388,11 @@ public class ARRAYS
|
||||
* Stable sort referres to Mergesort or Insertionsort
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] stableSort(KEY_TYPE[] array) {
|
||||
stableSort(array, 0, array.length);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -423,9 +427,11 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @param comp the Comparator that decides the sorting order
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] unstableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
unstableSort(array, 0, array.length, comp);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,9 +467,11 @@ public class ARRAYS
|
||||
* Unstable sort referres to QuickSort or SelectionSort
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] unstableSort(KEY_TYPE[] array) {
|
||||
unstableSort(array, 0, array.length);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,9 +504,11 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @param comp the Comparator that decides the sorting order
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] insertionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
insertionSort(array, 0, array.length, comp);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -535,9 +545,11 @@ public class ARRAYS
|
||||
* Sorts an array according to the natural ascending order using InsertionSort,
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] insertionSort(KEY_TYPE[] array) {
|
||||
insertionSort(array, 0, array.length);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,9 +585,11 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @param comp the Comparator that decides the sorting order
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] selectionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
selectionSort(array, 0, array.length, comp);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -617,9 +631,11 @@ public class ARRAYS
|
||||
* Sorts an array according to the natural ascending order using Selection Sort,
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] selectionSort(KEY_TYPE[] array) {
|
||||
selectionSort(array, 0, array.length);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,9 +677,11 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @param comp the Comparator that decides the sorting order
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] mergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
mergeSort(array, null, 0, array.length, comp);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,9 +731,11 @@ public class ARRAYS
|
||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] mergeSort(KEY_TYPE[] array) {
|
||||
mergeSort(array, null, 0, array.length);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -922,9 +942,11 @@ public class ARRAYS
|
||||
* @author Speiger
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] memFreeMergeSort(KEY_TYPE[] array) {
|
||||
memFreeMergeSort(array, 0, array.length);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1099,9 +1121,11 @@ public class ARRAYS
|
||||
* @param array the array that needs to be sorted
|
||||
* @param comp the Comparator that decides the sorting order
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] quickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
quickSort(array, 0, array.length, comp);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1157,9 +1181,11 @@ public class ARRAYS
|
||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
||||
* @param array the array that needs to be sorted
|
||||
* @ArrayType(T)
|
||||
* @return input array
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array) {
|
||||
public static GENERIC_KEY_BRACES KEY_TYPE[] quickSort(KEY_TYPE[] array) {
|
||||
quickSort(array, 0, array.length);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
@@ -113,6 +113,16 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
||||
return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
||||
* @param values that should be wrapped
|
||||
* @Type(T)
|
||||
* @return a AsyncBuilder with the values wrapped
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES ASYNC_BUILDER KEY_GENERIC_TYPE of(KEY_TYPE...values) {
|
||||
return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values));
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the elements to something else
|
||||
* @param mapper the mapping function
|
||||
|
||||
+11
-10
@@ -34,7 +34,7 @@ public class ITERATORS
|
||||
/**
|
||||
* Empty Iterator Reference
|
||||
*/
|
||||
public static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES();
|
||||
private static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES();
|
||||
|
||||
/**
|
||||
* Returns a Immutable EmptyIterator instance that is automatically casted.
|
||||
@@ -735,7 +735,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
return EMPTY_KEY_VALUE;
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -745,7 +745,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE PREVIOUS() {
|
||||
return EMPTY_KEY_VALUE;
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -787,6 +787,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return a[from++];
|
||||
}
|
||||
|
||||
@@ -854,7 +855,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
T result = last.next();
|
||||
foundNext = false;
|
||||
return result;
|
||||
@@ -890,7 +891,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
T result = last.next();
|
||||
foundNext = false;
|
||||
return result;
|
||||
@@ -921,7 +922,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return sortedElements.GET_KEY(index++);
|
||||
}
|
||||
}
|
||||
@@ -971,7 +972,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
foundNext = false;
|
||||
return lastFound;
|
||||
}
|
||||
@@ -1008,7 +1009,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
foundNext = false;
|
||||
return lastFound;
|
||||
}
|
||||
@@ -1031,7 +1032,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
limit--;
|
||||
return iterator.NEXT();
|
||||
}
|
||||
@@ -1054,7 +1055,7 @@ public class ITERATORS
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
KEY_TYPE result = iterator.NEXT();
|
||||
action.accept(result);
|
||||
return result;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class LISTS
|
||||
/**
|
||||
* Empty List reference
|
||||
*/
|
||||
public static final EmptyList NO_GENERIC_TYPE EMPTY = new EmptyListBRACES();
|
||||
private static final EmptyList NO_GENERIC_TYPE EMPTY = new EmptyListBRACES();
|
||||
|
||||
/**
|
||||
* Returns a Immutable EmptyList instance that is automatically casted.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package speiger.src.collections.PACKAGE.utils;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
#if TYPE_BOOLEAN
|
||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
||||
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
||||
@@ -34,7 +35,7 @@ public class SETS
|
||||
/**
|
||||
* Empty Set Variable
|
||||
*/
|
||||
public static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES();
|
||||
private static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES();
|
||||
|
||||
/**
|
||||
* EmptySet getter
|
||||
@@ -216,10 +217,10 @@ public class SETS
|
||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||
boolean next = true;
|
||||
@Override
|
||||
public boolean hasNext() { return next = false; }
|
||||
public boolean hasNext() { return next; }
|
||||
@Override
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!next) throw new IllegalStateException();
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
next = false;
|
||||
return element;
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,6 +1,7 @@
|
||||
package speiger.src.collections.PACKAGE.utils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Spliterator;
|
||||
#if PRIMITIVES
|
||||
import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
|
||||
@@ -329,7 +330,11 @@ public class SPLIT_ITERATORS
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE NEXT() { return array[index++]; }
|
||||
public KEY_TYPE NEXT() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
return array[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() { return index < fence; }
|
||||
}
|
||||
|
||||
+15
-14
@@ -57,7 +57,21 @@ public class MAPS
|
||||
/**
|
||||
* Empty Map Variable
|
||||
*/
|
||||
public static final MAP NO_KV_GENERIC_TYPE EMPTY = new EmptyMapKV_BRACES();
|
||||
private static final MAP NO_KV_GENERIC_TYPE EMPTY = new EmptyMapKV_BRACES();
|
||||
|
||||
/**
|
||||
* 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 empty() {
|
||||
#if TYPE_OBJECT || VALUE_OBJECT
|
||||
return (MAP KEY_VALUE_GENERIC_TYPE)EMPTY;
|
||||
#else
|
||||
return EMPTY;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
@@ -104,19 +118,6 @@ 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 empty() {
|
||||
#if TYPE_OBJECT || VALUE_OBJECT
|
||||
return (MAP KEY_VALUE_GENERIC_TYPE)EMPTY;
|
||||
#else
|
||||
return EMPTY;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that creates a Helper wrapper to synchronize access into the map.
|
||||
|
||||
Reference in New Issue
Block a user