Source Sync
This commit is contained in:
parent
91aabe2096
commit
4db9c69a54
@ -9,6 +9,13 @@ import java.util.Iterator;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
#if IARRAY_FEATURE || TYPE_OBJECT
|
#if IARRAY_FEATURE || TYPE_OBJECT
|
||||||
@ -225,6 +232,42 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a ArrayList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, ObjectArrayList<T>, ObjectArrayList<T>> toList() {
|
||||||
|
return Collector.of(ObjectArrayList::new, ObjectArrayList::add, ObjectArrayList::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> ARRAY_LIST KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
||||||
|
return stream.collect(ObjectArrayList::new, ObjectArrayList::add, ObjectArrayList::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ObjectArrayList<T> merge(ObjectArrayList<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static ARRAY_LIST toList(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(ARRAY_LIST::new, ARRAY_LIST::add, ARRAY_LIST::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Appends the specified element to the end of this list.
|
* Appends the specified element to the end of this list.
|
||||||
|
|||||||
@ -10,6 +10,12 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -172,7 +178,42 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a CopyOnWriteArrayList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, CopyOnWriteObjectArrayList<T>, CopyOnWriteObjectArrayList<T>> toList() {
|
||||||
|
return Collector.of(CopyOnWriteObjectArrayList::new, CopyOnWriteObjectArrayList::add, CopyOnWriteObjectArrayList::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a CopyOnWriteArrayList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> CopyOnWriteObjectArrayList KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
||||||
|
return stream.collect(CopyOnWriteObjectArrayList::new, CopyOnWriteObjectArrayList::add, CopyOnWriteObjectArrayList::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CopyOnWriteObjectArrayList<T> merge(CopyOnWriteObjectArrayList<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a CopyOnWriteArrayList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static COPY_ON_WRITE_LIST toList(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(COPY_ON_WRITE_LIST::new, COPY_ON_WRITE_LIST::add, COPY_ON_WRITE_LIST::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
private void setArray(KEY_TYPE[] data) {
|
private void setArray(KEY_TYPE[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,25 @@ package speiger.src.collections.PACKAGE.lists;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
#else if !TYPE_BOOLEAN
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if PRIMITIVES
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -23,6 +36,7 @@ import java.util.function.PREDICATE;
|
|||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -42,10 +56,6 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
|||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
#endif
|
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
@ -126,6 +136,42 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
data = Arrays.copyOfRange(a, offset, offset+length);
|
data = Arrays.copyOfRange(a, offset, offset+length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a ImmutableList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, COLLECTION<T>, ImmutableObjectList<T>> toList() {
|
||||||
|
return Collector.of(COLLECTIONS::wrapper, COLLECTION::add, ImmutableObjectList::merge, E -> new IMMUTABLE_LIST<>(E.toArray((T[])new Object[E.size()])));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ImmutableList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> ImmutableObjectList KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
||||||
|
return stream.collect(toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> COLLECTION<T> merge(COLLECTION<T> a, COLLECTION<T> b) {
|
||||||
|
a.addAll(b);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ImmutableList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static IMMUTABLE_LIST toList(JAVA_STREAM stream) {
|
||||||
|
return new IMMUTABLE_LIST(stream.collect((Supplier<COLLECTION>)COLLECTIONS::wrapper, COLLECTION::add, COLLECTION::addAll).TO_ARRAY());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
public boolean add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -13,6 +13,12 @@ import java.util.Iterator;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
@ -160,6 +166,42 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
for(int i = offset,m=offset+length;i<m;add(a[i++]));
|
for(int i = offset,m=offset+length;i<m;add(a[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a LinkedList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, ObjectLinkedList<T>, ObjectLinkedList<T>> toList() {
|
||||||
|
return Collector.of(ObjectLinkedList::new, ObjectLinkedList::add, ObjectLinkedList::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedList
|
||||||
|
* @Type(T)
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> ObjectLinkedList KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
||||||
|
return stream.collect(ObjectLinkedList::new, ObjectLinkedList::add, ObjectLinkedList::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ObjectLinkedList<T> merge(ObjectLinkedList<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static LINKED_LIST toList(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(LINKED_LIST::new, LINKED_LIST::add, LINKED_LIST::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE e) {
|
public boolean add(KEY_TYPE e) {
|
||||||
add(size(), e);
|
add(size(), e);
|
||||||
|
|||||||
@ -238,13 +238,13 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -252,7 +252,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -260,7 +260,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -272,13 +272,13 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -286,7 +286,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -294,7 +294,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -307,7 +307,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -318,7 +318,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -331,7 +331,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -342,7 +342,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -353,7 +353,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(isEmpty() || strategy.equals(FIRST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || strategy.equals(FIRST_ENTRY_KEY(), key)) return false;
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -375,7 +375,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(isEmpty() || strategy.equals(LAST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || strategy.equals(LAST_ENTRY_KEY(), key)) return false;
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -396,7 +396,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,8 +580,8 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -598,8 +598,8 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -215,13 +215,13 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
@ -229,7 +229,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -237,7 +237,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -249,13 +249,13 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
@ -263,7 +263,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -271,7 +271,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -284,7 +284,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
@ -295,7 +295,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -308,7 +308,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
@ -319,7 +319,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -330,7 +330,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(isEmpty() || KEY_EQUALS(FIRST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || KEY_EQUALS(FIRST_ENTRY_KEY(), key)) return false;
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
if(KEY_EQUALS_NULL(key)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -352,7 +352,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(isEmpty() || KEY_EQUALS(LAST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || KEY_EQUALS(LAST_ENTRY_KEY(), key)) return false;
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
if(KEY_EQUALS_NULL(key)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -373,7 +373,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,8 +584,8 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -602,8 +602,8 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -9,6 +9,14 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
@ -105,6 +113,47 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
this(MIN_CAPACITY);
|
this(MIN_CAPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a ArrayFIFOQueue
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, ARRAY_FIFO_QUEUE<T>, ARRAY_FIFO_QUEUE<T>> toQueue() {
|
||||||
|
return Collector.of(ARRAY_FIFO_QUEUE::new, ARRAY_FIFO_QUEUE::enqueue, ARRAY_FIFO_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayFIFOQueue
|
||||||
|
* @Type(T)
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE toQueue(Stream<T> stream) {
|
||||||
|
return stream.collect(ARRAY_FIFO_QUEUE::new, ARRAY_FIFO_QUEUE::enqueue, ARRAY_FIFO_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ARRAY_FIFO_QUEUE<T> merge(ARRAY_FIFO_QUEUE<T> a) {
|
||||||
|
enqueueAll(a.toArray((T[])new Object[a.size()]));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayFIFOQueue
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static ARRAY_FIFO_QUEUE toQueue(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(ARRAY_FIFO_QUEUE::new, ARRAY_FIFO_QUEUE::enqueue, ARRAY_FIFO_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ARRAY_FIFO_QUEUE merge(ARRAY_FIFO_QUEUE a) {
|
||||||
|
enqueueAll(a.TO_ARRAY());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
|
|||||||
@ -10,6 +10,14 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
@ -196,7 +204,47 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a ArrayPriorityQueue
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, ARRAY_PRIORITY_QUEUE<T>, ARRAY_PRIORITY_QUEUE<T>> toQueue() {
|
||||||
|
return Collector.of(ARRAY_PRIORITY_QUEUE::new, ARRAY_PRIORITY_QUEUE::enqueue, ARRAY_PRIORITY_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayPriorityQueue
|
||||||
|
* @Type(T)
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE toQueue(Stream<T> stream) {
|
||||||
|
return stream.collect(ARRAY_PRIORITY_QUEUE::new, ARRAY_PRIORITY_QUEUE::enqueue, ARRAY_PRIORITY_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ARRAY_PRIORITY_QUEUE<T> merge(ARRAY_PRIORITY_QUEUE<T> a) {
|
||||||
|
enqueueAll(a.toArray((T[])new Object[a.size()]));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayPriorityQueue
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static ARRAY_PRIORITY_QUEUE toQueue(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(ARRAY_PRIORITY_QUEUE::new, ARRAY_PRIORITY_QUEUE::enqueue, ARRAY_PRIORITY_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ARRAY_PRIORITY_QUEUE merge(ARRAY_PRIORITY_QUEUE a) {
|
||||||
|
enqueueAll(a.TO_ARRAY());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE e) {
|
||||||
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(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));
|
||||||
|
|||||||
@ -10,6 +10,14 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
@ -199,6 +207,47 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a ArrayFIFOQueue
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, HEAP_PRIORITY_QUEUE<T>, HEAP_PRIORITY_QUEUE<T>> toQueue() {
|
||||||
|
return Collector.of(HEAP_PRIORITY_QUEUE::new, HEAP_PRIORITY_QUEUE::enqueue, HEAP_PRIORITY_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayFIFOQueue
|
||||||
|
* @Type(T)
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE toQueue(Stream<T> stream) {
|
||||||
|
return stream.collect(HEAP_PRIORITY_QUEUE::new, HEAP_PRIORITY_QUEUE::enqueue, HEAP_PRIORITY_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HEAP_PRIORITY_QUEUE<T> merge(HEAP_PRIORITY_QUEUE<T> a) {
|
||||||
|
enqueueAll(a.toArray((T[])new Object[a.size()]));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayFIFOQueue
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static HEAP_PRIORITY_QUEUE toQueue(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(HEAP_PRIORITY_QUEUE::new, HEAP_PRIORITY_QUEUE::enqueue, HEAP_PRIORITY_QUEUE::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HEAP_PRIORITY_QUEUE merge(HEAP_PRIORITY_QUEUE a) {
|
||||||
|
enqueueAll(a.TO_ARRAY());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
@ -12,6 +12,12 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
@ -214,6 +220,42 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a AVLTreeSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, AVL_TREE_SET<T>, AVL_TREE_SET<T>> toSet() {
|
||||||
|
return Collector.of(AVL_TREE_SET::new, AVL_TREE_SET::add, AVL_TREE_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a AVLTreeSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> AVL_TREE_SET KEY_GENERIC_TYPE toSet(Stream<T> stream) {
|
||||||
|
return stream.collect(AVL_TREE_SET::new, AVL_TREE_SET::add, AVL_TREE_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AVL_TREE_SET<T> merge(AVL_TREE_SET<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a AVLTreeSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static AVL_TREE_SET toSet(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(AVL_TREE_SET::new, AVL_TREE_SET::add, AVL_TREE_SET::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
||||||
|
|||||||
@ -10,6 +10,12 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
@ -74,7 +80,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
* @param array the array that should be used for set.
|
* @param array the array that should be used for set.
|
||||||
*/
|
*/
|
||||||
public ARRAY_SET(KEY_TYPE[] array) {
|
public ARRAY_SET(KEY_TYPE[] array) {
|
||||||
this(array, array.length);
|
this(array, 0, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,6 +94,18 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
addAll(array, length);
|
addAll(array, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructur using initial Array
|
||||||
|
* @param array the array that should be used for set.
|
||||||
|
* @param offset the starting offset of where the array should be copied from
|
||||||
|
* @param length the amount of elements present within the array
|
||||||
|
* @throws NegativeArraySizeException if the length is negative
|
||||||
|
*/
|
||||||
|
public ARRAY_SET(KEY_TYPE[] array, int offset, int length) {
|
||||||
|
this(length);
|
||||||
|
addAll(array, offset, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
||||||
* @param c the elements that should be added to the set.
|
* @param c the elements that should be added to the set.
|
||||||
@ -131,6 +149,42 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
for(ITERATOR KEY_GENERIC_TYPE iter = s.iterator();iter.hasNext();data[size++] = iter.NEXT());
|
for(ITERATOR KEY_GENERIC_TYPE iter = s.iterator();iter.hasNext();data[size++] = iter.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a ArraySet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, ARRAY_SET<T>, ARRAY_SET<T>> toList() {
|
||||||
|
return Collector.of(ARRAY_SET::new, ARRAY_SET::add, ARRAY_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArraySet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> ARRAY_SET KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
||||||
|
return stream.collect(ARRAY_SET::new, ARRAY_SET::add, ARRAY_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ARRAY_SET<T> merge(ARRAY_SET<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArraySet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static ARRAY_SET toList(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(ARRAY_SET::new, ARRAY_SET::add, ARRAY_SET::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE o) {
|
public boolean add(KEY_TYPE o) {
|
||||||
int index = findIndex(o);
|
int index = findIndex(o);
|
||||||
|
|||||||
@ -11,6 +11,12 @@ import java.util.Iterator;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
@ -240,6 +246,42 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a LinkedCustomHashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, LINKED_CUSTOM_HASH_SET<T>, LINKED_CUSTOM_HASH_SET<T>> toLinkedSet(STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
||||||
|
return Collector.of(() -> new LINKED_CUSTOM_HASH_SET<>(strategy), LINKED_CUSTOM_HASH_SET::add, LINKED_CUSTOM_HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedCustomHashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE toLinkedSet(Stream<T> stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
||||||
|
return stream.collect(() -> new LINKED_CUSTOM_HASH_SET<>(strategy), LINKED_CUSTOM_HASH_SET::add, LINKED_CUSTOM_HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LINKED_CUSTOM_HASH_SET<T> merge(LINKED_CUSTOM_HASH_SET<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedCustomHashSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static LINKED_CUSTOM_HASH_SET toList(JAVA_STREAM stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
||||||
|
return stream.collect(() -> new LINKED_CUSTOM_HASH_SET(strategy), LINKED_CUSTOM_HASH_SET::add, LINKED_CUSTOM_HASH_SET::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(KEY_TYPE o) {
|
public void addFirst(KEY_TYPE o) {
|
||||||
|
|||||||
@ -7,6 +7,12 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -211,6 +217,42 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a LinkedHashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, LINKED_HASH_SET<T>, LINKED_HASH_SET<T>> toLinkedSet() {
|
||||||
|
return Collector.of(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedHashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> LINKED_HASH_SET KEY_GENERIC_TYPE toLinkedSet(Stream<T> stream) {
|
||||||
|
return stream.collect(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LINKED_HASH_SET<T> merge(LINKED_HASH_SET<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedHashSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static LINKED_HASH_SET toLinkedSet(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(KEY_TYPE o) {
|
public void addFirst(KEY_TYPE o) {
|
||||||
|
|||||||
@ -8,6 +8,12 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -257,6 +263,42 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a CustomHashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, CUSTOM_HASH_SET<T>, CUSTOM_HASH_SET<T>> toSet(STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
||||||
|
return Collector.of(() -> new CUSTOM_HASH_SET<>(strategy), CUSTOM_HASH_SET::add, CUSTOM_HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a CustomHashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> CUSTOM_HASH_SET KEY_GENERIC_TYPE toSet(Stream<T> stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
||||||
|
return stream.collect(() -> new CUSTOM_HASH_SET<>(strategy), CUSTOM_HASH_SET::add, CUSTOM_HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CUSTOM_HASH_SET<T> merge(CUSTOM_HASH_SET<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a CustomHashSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static CUSTOM_HASH_SET toSet(JAVA_STREAM stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
||||||
|
return stream.collect(() -> new CUSTOM_HASH_SET(strategy), CUSTOM_HASH_SET::add, CUSTOM_HASH_SET::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Helper getter function to get the current strategy
|
* Helper getter function to get the current strategy
|
||||||
|
|||||||
@ -8,6 +8,12 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -224,6 +230,42 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a HashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, HASH_SET<T>, HASH_SET<T>> toSet() {
|
||||||
|
return Collector.of(HASH_SET::new, HASH_SET::add, HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a HashSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> HASH_SET KEY_GENERIC_TYPE toSet(Stream<T> stream) {
|
||||||
|
return stream.collect(HASH_SET::new, HASH_SET::add, HASH_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HASH_SET<T> merge(HASH_SET<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a HashSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static HASH_SET toSet(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(HASH_SET::new, HASH_SET::add, HASH_SET::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE o) {
|
public boolean add(KEY_TYPE o) {
|
||||||
|
|||||||
@ -4,6 +4,12 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
#if JDK_TYPE
|
#if JDK_TYPE
|
||||||
import java.util.OPTIONAL;
|
import java.util.OPTIONAL;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
#else
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -214,6 +220,42 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Creates a Collector for a RBTreeSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a collector
|
||||||
|
*/
|
||||||
|
public static <T> Collector<T, RB_TREE_SET<T>, RB_TREE_SET<T>> toSet() {
|
||||||
|
return Collector.of(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a RBTreeSet
|
||||||
|
* @Type(T)
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static <T> RB_TREE_SET KEY_GENERIC_TYPE toSet(Stream<T> stream) {
|
||||||
|
return stream.collect(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RB_TREE_SET<T> merge(RB_TREE_SET<T> a) {
|
||||||
|
addAll(a);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a RBTreeSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static RB_TREE_SET toSet(JAVA_STREAM stream) {
|
||||||
|
return stream.collect(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
||||||
|
|||||||
@ -7,6 +7,11 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
#if JDK_TYPE
|
||||||
|
import java.util.OPTIONAL;
|
||||||
|
#else
|
||||||
|
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -299,9 +304,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
* @param operator that reduces the elements.
|
* @param operator that reduces the elements.
|
||||||
* @return self with the reduce action applied
|
* @return self with the reduce action applied
|
||||||
*/
|
*/
|
||||||
public ASYNC_BUILDER KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public ObjectAsyncBuilder<OPTIONAL KEY_GENERIC_TYPE> reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
task = new SimpleReduceTaskBRACES(iterable.iterator(), operator);
|
return new ObjectAsyncBuilder<>(new SimpleReduceTaskBRACES(iterable.iterator(), operator));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@ -435,9 +439,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
* @return self with the findFirst function applied
|
* @return self with the findFirst function applied
|
||||||
*/
|
*/
|
||||||
public ASYNC_BUILDER KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public ObjectAsyncBuilder<OPTIONAL KEY_GENERIC_TYPE> findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
task = new FindFirstTaskBRACES(iterable.iterator(), filter);
|
return new ObjectAsyncBuilder<>(new FindFirstTaskBRACES(iterable.iterator(), filter));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INT_ASYNC_MODULE
|
#if INT_ASYNC_MODULE
|
||||||
@ -590,7 +593,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
private static class SimpleReduceTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
private static class SimpleReduceTask KEY_GENERIC_TYPE extends BaseObjectTask<OPTIONAL KEY_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator;
|
UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator;
|
||||||
@ -600,6 +603,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
public SimpleReduceTask(ITERATOR KEY_GENERIC_TYPE iter, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public SimpleReduceTask(ITERATOR KEY_GENERIC_TYPE iter, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
|
this.setResult(OPTIONAL.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -614,7 +618,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!iter.hasNext()) {
|
if(!iter.hasNext()) {
|
||||||
setResult(value);
|
setResult(OPTIONAL.GET_OPTIONAL(value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -689,7 +693,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
private static class FindFirstTask KEY_GENERIC_TYPE extends BaseObjectTask<OPTIONAL KEY_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
PREDICATE KEY_GENERIC_TYPE filter;
|
PREDICATE KEY_GENERIC_TYPE filter;
|
||||||
@ -697,6 +701,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
public FindFirstTask(ITERATOR KEY_GENERIC_TYPE iter, PREDICATE KEY_GENERIC_TYPE filter) {
|
public FindFirstTask(ITERATOR KEY_GENERIC_TYPE iter, PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
this.setResult(OPTIONAL.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -704,7 +709,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
KEY_TYPE entry = iter.NEXT();
|
KEY_TYPE entry = iter.NEXT();
|
||||||
if(filter.test(iter.NEXT())) {
|
if(filter.test(iter.NEXT())) {
|
||||||
setResult(entry);
|
setResult(OPTIONAL.GET_OPTIONAL(entry));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,7 +147,10 @@ public class COLLECTIONS
|
|||||||
return new SingletonCollectionBRACES(element);
|
return new SingletonCollectionBRACES(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
|
/**
|
||||||
|
* Internal Use mainly. Its a collection wrapper with 0 dependencies for those actions where a collector is needed.
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
|
||||||
return new CollectionWrapperBRACES();
|
return new CollectionWrapperBRACES();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BU
|
|||||||
features.addAll(parentBuilder.getFeatures());
|
features.addAll(parentBuilder.getFeatures());
|
||||||
features.remove(SpecialFeature.COPYING);
|
features.remove(SpecialFeature.COPYING);
|
||||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
return ORDERED_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.ReverseTestOrderedMapGenerator(delegate))
|
return ORDERED_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.ReverseTestOrderedMapGeneratorKV_BRACES(delegate))
|
||||||
.named(parentBuilder.getName() + " reversed").withFeatures(features)
|
.named(parentBuilder.getName() + " reversed").withFeatures(features)
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapPutTester KEY_VALUE_GENERIC_
|
|||||||
private ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> values;
|
private ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> values;
|
||||||
private KEY_TYPE a;
|
private KEY_TYPE a;
|
||||||
private VALUE_TYPE aValue;
|
private VALUE_TYPE aValue;
|
||||||
private VALUE_TYPE cValue;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@ -33,9 +32,6 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapPutTester KEY_VALUE_GENERIC_
|
|||||||
if (values.size() >= 1) {
|
if (values.size() >= 1) {
|
||||||
a = values.get(0).ENTRY_KEY();
|
a = values.get(0).ENTRY_KEY();
|
||||||
aValue = values.get(0).ENTRY_VALUE();
|
aValue = values.get(0).ENTRY_VALUE();
|
||||||
if (values.size() >= 3) {
|
|
||||||
cValue = values.get(2).ENTRY_VALUE();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,10 +40,10 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapPutTester KEY_VALUE_GENERIC_
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testPutFirst() {
|
public void testPutFirst() {
|
||||||
assertEquals(aValue, orderedMap.putFirst(a, cValue));
|
assertEquals(aValue, orderedMap.putFirst(a, v3()));
|
||||||
assertNotEquals(cValue, orderedMap.FIRST_ENTRY_VALUE());
|
assertNotEquals(v3(), orderedMap.FIRST_ENTRY_VALUE());
|
||||||
assertEquals(orderedMap.getDefaultReturnValue(), orderedMap.putFirst(k4(), v4()));
|
assertEquals(orderedMap.getDefaultReturnValue(), orderedMap.putFirst(k4(), v4()));
|
||||||
assertNotEquals(v4(), orderedMap.FIRST_ENTRY_VALUE());
|
assertEquals(v4(), orderedMap.FIRST_ENTRY_VALUE());
|
||||||
assertEquals(e4(), orderedMap.firstEntry());
|
assertEquals(e4(), orderedMap.firstEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,10 +53,10 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapPutTester KEY_VALUE_GENERIC_
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testPutLast() {
|
public void testPutLast() {
|
||||||
assertEquals(aValue, orderedMap.putLast(a, cValue));
|
assertEquals(aValue, orderedMap.putLast(a, v3()));
|
||||||
assertNotEquals(cValue, orderedMap.LAST_ENTRY_VALUE());
|
assertNotEquals(v3(), orderedMap.LAST_ENTRY_VALUE());
|
||||||
assertEquals(orderedMap.getDefaultReturnValue(), orderedMap.putLast(k4(), v4()));
|
assertEquals(orderedMap.getDefaultReturnValue(), orderedMap.putLast(k4(), v4()));
|
||||||
assertNotEquals(v4(), orderedMap.LAST_ENTRY_VALUE());
|
assertEquals(v4(), orderedMap.LAST_ENTRY_VALUE());
|
||||||
assertEquals(e4(), orderedMap.lastEntry());
|
assertEquals(e4(), orderedMap.lastEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,6 @@ public class CopyOnWriteBooleanArrayList extends AbstractBooleanList implements
|
|||||||
System.arraycopy(a, offset, data, 0, length);
|
System.arraycopy(a, offset, data, 0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setArray(boolean[] data) {
|
private void setArray(boolean[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,7 +174,6 @@ public class BooleanArrayPriorityQueue extends AbstractBooleanPriorityQueue
|
|||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(boolean e) {
|
public void enqueue(boolean e) {
|
||||||
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(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));
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import speiger.src.collections.booleans.functions.OptionalBoolean;
|
||||||
|
|
||||||
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
||||||
import speiger.src.collections.booleans.functions.BooleanComparator;
|
import speiger.src.collections.booleans.functions.BooleanComparator;
|
||||||
@ -207,9 +208,8 @@ public class BooleanAsyncBuilder
|
|||||||
* @param operator that reduces the elements.
|
* @param operator that reduces the elements.
|
||||||
* @return self with the reduce action applied
|
* @return self with the reduce action applied
|
||||||
*/
|
*/
|
||||||
public BooleanAsyncBuilder reduce(BooleanBooleanUnaryOperator operator) {
|
public ObjectAsyncBuilder<OptionalBoolean> reduce(BooleanBooleanUnaryOperator operator) {
|
||||||
task = new SimpleReduceTask(iterable.iterator(), operator);
|
return new ObjectAsyncBuilder<>(new SimpleReduceTask(iterable.iterator(), operator));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -281,9 +281,8 @@ public class BooleanAsyncBuilder
|
|||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
* @return self with the findFirst function applied
|
* @return self with the findFirst function applied
|
||||||
*/
|
*/
|
||||||
public BooleanAsyncBuilder findFirst(BooleanPredicate filter) {
|
public ObjectAsyncBuilder<OptionalBoolean> findFirst(BooleanPredicate filter) {
|
||||||
task = new FindFirstTask(iterable.iterator(), filter);
|
return new ObjectAsyncBuilder<>(new FindFirstTask(iterable.iterator(), filter));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -393,7 +392,7 @@ public class BooleanAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SimpleReduceTask extends BaseBooleanTask
|
private static class SimpleReduceTask extends BaseObjectTask<OptionalBoolean>
|
||||||
{
|
{
|
||||||
BooleanIterator iter;
|
BooleanIterator iter;
|
||||||
BooleanBooleanUnaryOperator operator;
|
BooleanBooleanUnaryOperator operator;
|
||||||
@ -403,6 +402,7 @@ public class BooleanAsyncBuilder
|
|||||||
public SimpleReduceTask(BooleanIterator iter, BooleanBooleanUnaryOperator operator) {
|
public SimpleReduceTask(BooleanIterator iter, BooleanBooleanUnaryOperator operator) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
|
this.setResult(OptionalBoolean.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -417,7 +417,7 @@ public class BooleanAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!iter.hasNext()) {
|
if(!iter.hasNext()) {
|
||||||
setResult(value);
|
setResult(OptionalBoolean.of(value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -487,7 +487,7 @@ public class BooleanAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FindFirstTask extends BaseBooleanTask
|
private static class FindFirstTask extends BaseObjectTask<OptionalBoolean>
|
||||||
{
|
{
|
||||||
BooleanIterator iter;
|
BooleanIterator iter;
|
||||||
BooleanPredicate filter;
|
BooleanPredicate filter;
|
||||||
@ -495,6 +495,7 @@ public class BooleanAsyncBuilder
|
|||||||
public FindFirstTask(BooleanIterator iter, BooleanPredicate filter) {
|
public FindFirstTask(BooleanIterator iter, BooleanPredicate filter) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
this.setResult(OptionalBoolean.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -502,7 +503,7 @@ public class BooleanAsyncBuilder
|
|||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
boolean entry = iter.nextBoolean();
|
boolean entry = iter.nextBoolean();
|
||||||
if(filter.test(iter.nextBoolean())) {
|
if(filter.test(iter.nextBoolean())) {
|
||||||
setResult(entry);
|
setResult(OptionalBoolean.of(entry));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,7 +106,10 @@ public class BooleanCollections
|
|||||||
return new SingletonCollection(element);
|
return new SingletonCollection(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static CollectionWrapper wrapper() {
|
/**
|
||||||
|
* Internal Use mainly. Its a collection wrapper with 0 dependencies for those actions where a collector is needed.
|
||||||
|
*/
|
||||||
|
public static CollectionWrapper wrapper() {
|
||||||
return new CollectionWrapper();
|
return new CollectionWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -111,7 +111,6 @@ public class CopyOnWriteByteArrayList extends AbstractByteList implements ITrimm
|
|||||||
System.arraycopy(a, offset, data, 0, length);
|
System.arraycopy(a, offset, data, 0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setArray(byte[] data) {
|
private void setArray(byte[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
package speiger.src.collections.bytes.lists;
|
package speiger.src.collections.bytes.lists;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
import java.util.function.IntPredicate;import java.util.function.IntUnaryOperator;
|
import java.util.function.IntPredicate;
|
||||||
|
import java.util.function.IntUnaryOperator;
|
||||||
|
|
||||||
import speiger.src.collections.bytes.collections.ByteCollection;
|
import speiger.src.collections.bytes.collections.ByteCollection;
|
||||||
import speiger.src.collections.bytes.functions.ByteComparator;
|
import speiger.src.collections.bytes.functions.ByteComparator;
|
||||||
@ -18,8 +21,6 @@ import speiger.src.collections.bytes.functions.function.BytePredicate;
|
|||||||
import speiger.src.collections.bytes.functions.function.ByteByteUnaryOperator;
|
import speiger.src.collections.bytes.functions.function.ByteByteUnaryOperator;
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.bytes.utils.ByteIterators;
|
import speiger.src.collections.bytes.utils.ByteIterators;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
import speiger.src.collections.bytes.collections.ByteSplititerator;
|
import speiger.src.collections.bytes.collections.ByteSplititerator;
|
||||||
import speiger.src.collections.bytes.utils.ByteSplititerators;
|
import speiger.src.collections.bytes.utils.ByteSplititerators;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
public boolean getAndMoveToFirst(byte key) {
|
public boolean getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
public boolean getAndMoveToLast(byte key) {
|
public boolean getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Byte2BooleanLinkedOpenCustomHashMap extends Byte2BooleanOpenCustomH
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -191,13 +191,13 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -205,7 +205,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -225,13 +225,13 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -239,7 +239,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -260,7 +260,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -271,7 +271,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -284,7 +284,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -295,7 +295,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -306,7 +306,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -328,7 +328,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -349,7 +349,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
public byte getAndMoveToFirst(byte key) {
|
public byte getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
public byte getAndMoveToLast(byte key) {
|
public byte getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,8 +533,8 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -551,8 +551,8 @@ public class Byte2ByteLinkedOpenCustomHashMap extends Byte2ByteOpenCustomHashMap
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
public char getAndMoveToFirst(byte key) {
|
public char getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
public char getAndMoveToLast(byte key) {
|
public char getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Byte2CharLinkedOpenCustomHashMap extends Byte2CharOpenCustomHashMap
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
public double getAndMoveToFirst(byte key) {
|
public double getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
public double getAndMoveToLast(byte key) {
|
public double getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Byte2DoubleLinkedOpenCustomHashMap extends Byte2DoubleOpenCustomHas
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
public float getAndMoveToFirst(byte key) {
|
public float getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
public float getAndMoveToLast(byte key) {
|
public float getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Byte2FloatLinkedOpenCustomHashMap extends Byte2FloatOpenCustomHashM
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
public int getAndMoveToFirst(byte key) {
|
public int getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
public int getAndMoveToLast(byte key) {
|
public int getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Byte2IntLinkedOpenCustomHashMap extends Byte2IntOpenCustomHashMap i
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
public long getAndMoveToFirst(byte key) {
|
public long getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
public long getAndMoveToLast(byte key) {
|
public long getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Byte2LongLinkedOpenCustomHashMap extends Byte2LongOpenCustomHashMap
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -193,13 +193,13 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -207,7 +207,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -215,7 +215,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -227,13 +227,13 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -241,7 +241,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -249,7 +249,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -262,7 +262,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -273,7 +273,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -286,7 +286,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -297,7 +297,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -308,7 +308,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -330,7 +330,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -351,7 +351,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
public V getAndMoveToFirst(byte key) {
|
public V getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
public V getAndMoveToLast(byte key) {
|
public V getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,8 +535,8 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -553,8 +553,8 @@ public class Byte2ObjectLinkedOpenCustomHashMap<V> extends Byte2ObjectOpenCustom
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastByteKey(), key)) return false;
|
||||||
if(strategy.equals(key, (byte)0)) {
|
if(strategy.equals(key, (byte)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (byte)0)) {
|
while(!strategy.equals(keys[pos], (byte)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
public short getAndMoveToFirst(byte key) {
|
public short getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
public short getAndMoveToLast(byte key) {
|
public short getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Byte2ShortLinkedOpenCustomHashMap extends Byte2ShortOpenCustomHashM
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
public boolean getAndMoveToFirst(byte key) {
|
public boolean getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
public boolean getAndMoveToLast(byte key) {
|
public boolean getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Byte2BooleanLinkedOpenHashMap extends Byte2BooleanOpenHashMap imple
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -168,13 +168,13 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -182,7 +182,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -202,13 +202,13 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -216,7 +216,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -237,7 +237,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -248,7 +248,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -261,7 +261,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -272,7 +272,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -283,7 +283,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -305,7 +305,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -326,7 +326,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
public byte getAndMoveToFirst(byte key) {
|
public byte getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
public byte getAndMoveToLast(byte key) {
|
public byte getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,8 +531,8 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -549,8 +549,8 @@ public class Byte2ByteLinkedOpenHashMap extends Byte2ByteOpenHashMap implements
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
public char getAndMoveToFirst(byte key) {
|
public char getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
public char getAndMoveToLast(byte key) {
|
public char getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Byte2CharLinkedOpenHashMap extends Byte2CharOpenHashMap implements
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
public double getAndMoveToFirst(byte key) {
|
public double getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
public double getAndMoveToLast(byte key) {
|
public double getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Byte2DoubleLinkedOpenHashMap extends Byte2DoubleOpenHashMap impleme
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
public float getAndMoveToFirst(byte key) {
|
public float getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
public float getAndMoveToLast(byte key) {
|
public float getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Byte2FloatLinkedOpenHashMap extends Byte2FloatOpenHashMap implement
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
public int getAndMoveToFirst(byte key) {
|
public int getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
public int getAndMoveToLast(byte key) {
|
public int getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Byte2IntLinkedOpenHashMap extends Byte2IntOpenHashMap implements By
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
public long getAndMoveToFirst(byte key) {
|
public long getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
public long getAndMoveToLast(byte key) {
|
public long getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Byte2LongLinkedOpenHashMap extends Byte2LongOpenHashMap implements
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -170,13 +170,13 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -184,7 +184,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -192,7 +192,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -204,13 +204,13 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -218,7 +218,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -226,7 +226,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -239,7 +239,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -250,7 +250,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -263,7 +263,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -274,7 +274,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -285,7 +285,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -307,7 +307,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -328,7 +328,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
public V getAndMoveToFirst(byte key) {
|
public V getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
public V getAndMoveToLast(byte key) {
|
public V getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,8 +522,8 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -540,8 +540,8 @@ public class Byte2ObjectLinkedOpenHashMap<V> extends Byte2ObjectOpenHashMap<V> i
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
if(isEmpty() || firstByteKey() == key) return false;
|
if(isEmpty() || firstByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
if(isEmpty() || lastByteKey() == key) return false;
|
if(isEmpty() || lastByteKey() == key) return false;
|
||||||
if(key == (byte)0) {
|
if(key == (byte)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Byte.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (byte)0) {
|
while(keys[pos] != (byte)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
public short getAndMoveToFirst(byte key) {
|
public short getAndMoveToFirst(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
public short getAndMoveToLast(byte key) {
|
public short getAndMoveToLast(byte key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Byte2ShortLinkedOpenHashMap extends Byte2ShortOpenHashMap implement
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -174,7 +174,6 @@ public class ByteArrayPriorityQueue extends AbstractBytePriorityQueue
|
|||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(byte e) {
|
public void enqueue(byte e) {
|
||||||
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(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));
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class ByteArraySet extends AbstractByteSet implements ByteOrderedSet
|
|||||||
* @param array the array that should be used for set.
|
* @param array the array that should be used for set.
|
||||||
*/
|
*/
|
||||||
public ByteArraySet(byte[] array) {
|
public ByteArraySet(byte[] array) {
|
||||||
this(array, array.length);
|
this(array, 0, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,6 +69,18 @@ public class ByteArraySet extends AbstractByteSet implements ByteOrderedSet
|
|||||||
addAll(array, length);
|
addAll(array, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructur using initial Array
|
||||||
|
* @param array the array that should be used for set.
|
||||||
|
* @param offset the starting offset of where the array should be copied from
|
||||||
|
* @param length the amount of elements present within the array
|
||||||
|
* @throws NegativeArraySizeException if the length is negative
|
||||||
|
*/
|
||||||
|
public ByteArraySet(byte[] array, int offset, int length) {
|
||||||
|
this(length);
|
||||||
|
addAll(array, offset, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
||||||
* @param c the elements that should be added to the set.
|
* @param c the elements that should be added to the set.
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import speiger.src.collections.bytes.functions.OptionalByte;
|
||||||
|
|
||||||
import speiger.src.collections.bytes.functions.ByteConsumer;
|
import speiger.src.collections.bytes.functions.ByteConsumer;
|
||||||
import speiger.src.collections.bytes.functions.ByteComparator;
|
import speiger.src.collections.bytes.functions.ByteComparator;
|
||||||
@ -210,9 +211,8 @@ public class ByteAsyncBuilder
|
|||||||
* @param operator that reduces the elements.
|
* @param operator that reduces the elements.
|
||||||
* @return self with the reduce action applied
|
* @return self with the reduce action applied
|
||||||
*/
|
*/
|
||||||
public ByteAsyncBuilder reduce(ByteByteUnaryOperator operator) {
|
public ObjectAsyncBuilder<OptionalByte> reduce(ByteByteUnaryOperator operator) {
|
||||||
task = new SimpleReduceTask(iterable.iterator(), operator);
|
return new ObjectAsyncBuilder<>(new SimpleReduceTask(iterable.iterator(), operator));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,9 +292,8 @@ public class ByteAsyncBuilder
|
|||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
* @return self with the findFirst function applied
|
* @return self with the findFirst function applied
|
||||||
*/
|
*/
|
||||||
public ByteAsyncBuilder findFirst(BytePredicate filter) {
|
public ObjectAsyncBuilder<OptionalByte> findFirst(BytePredicate filter) {
|
||||||
task = new FindFirstTask(iterable.iterator(), filter);
|
return new ObjectAsyncBuilder<>(new FindFirstTask(iterable.iterator(), filter));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -404,7 +403,7 @@ public class ByteAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SimpleReduceTask extends BaseByteTask
|
private static class SimpleReduceTask extends BaseObjectTask<OptionalByte>
|
||||||
{
|
{
|
||||||
ByteIterator iter;
|
ByteIterator iter;
|
||||||
ByteByteUnaryOperator operator;
|
ByteByteUnaryOperator operator;
|
||||||
@ -414,6 +413,7 @@ public class ByteAsyncBuilder
|
|||||||
public SimpleReduceTask(ByteIterator iter, ByteByteUnaryOperator operator) {
|
public SimpleReduceTask(ByteIterator iter, ByteByteUnaryOperator operator) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
|
this.setResult(OptionalByte.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -428,7 +428,7 @@ public class ByteAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!iter.hasNext()) {
|
if(!iter.hasNext()) {
|
||||||
setResult(value);
|
setResult(OptionalByte.of(value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -498,7 +498,7 @@ public class ByteAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FindFirstTask extends BaseByteTask
|
private static class FindFirstTask extends BaseObjectTask<OptionalByte>
|
||||||
{
|
{
|
||||||
ByteIterator iter;
|
ByteIterator iter;
|
||||||
BytePredicate filter;
|
BytePredicate filter;
|
||||||
@ -506,6 +506,7 @@ public class ByteAsyncBuilder
|
|||||||
public FindFirstTask(ByteIterator iter, BytePredicate filter) {
|
public FindFirstTask(ByteIterator iter, BytePredicate filter) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
this.setResult(OptionalByte.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -513,7 +514,7 @@ public class ByteAsyncBuilder
|
|||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
byte entry = iter.nextByte();
|
byte entry = iter.nextByte();
|
||||||
if(filter.test(iter.nextByte())) {
|
if(filter.test(iter.nextByte())) {
|
||||||
setResult(entry);
|
setResult(OptionalByte.of(entry));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,7 +109,10 @@ public class ByteCollections
|
|||||||
return new SingletonCollection(element);
|
return new SingletonCollection(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static CollectionWrapper wrapper() {
|
/**
|
||||||
|
* Internal Use mainly. Its a collection wrapper with 0 dependencies for those actions where a collector is needed.
|
||||||
|
*/
|
||||||
|
public static CollectionWrapper wrapper() {
|
||||||
return new CollectionWrapper();
|
return new CollectionWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -111,7 +111,6 @@ public class CopyOnWriteCharArrayList extends AbstractCharList implements ITrimm
|
|||||||
System.arraycopy(a, offset, data, 0, length);
|
System.arraycopy(a, offset, data, 0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setArray(char[] data) {
|
private void setArray(char[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
package speiger.src.collections.chars.lists;
|
package speiger.src.collections.chars.lists;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
import java.util.function.IntPredicate;import java.util.function.IntUnaryOperator;
|
import java.util.function.IntPredicate;
|
||||||
|
import java.util.function.IntUnaryOperator;
|
||||||
|
|
||||||
import speiger.src.collections.chars.collections.CharCollection;
|
import speiger.src.collections.chars.collections.CharCollection;
|
||||||
import speiger.src.collections.chars.functions.CharComparator;
|
import speiger.src.collections.chars.functions.CharComparator;
|
||||||
@ -18,8 +21,6 @@ import speiger.src.collections.chars.functions.function.CharPredicate;
|
|||||||
import speiger.src.collections.chars.functions.function.CharCharUnaryOperator;
|
import speiger.src.collections.chars.functions.function.CharCharUnaryOperator;
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.chars.utils.CharIterators;
|
import speiger.src.collections.chars.utils.CharIterators;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
import speiger.src.collections.chars.collections.CharSplititerator;
|
import speiger.src.collections.chars.collections.CharSplititerator;
|
||||||
import speiger.src.collections.chars.utils.CharSplititerators;
|
import speiger.src.collections.chars.utils.CharSplititerators;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
public boolean getAndMoveToFirst(char key) {
|
public boolean getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
public boolean getAndMoveToLast(char key) {
|
public boolean getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Char2BooleanLinkedOpenCustomHashMap extends Char2BooleanOpenCustomH
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
public byte getAndMoveToFirst(char key) {
|
public byte getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
public byte getAndMoveToLast(char key) {
|
public byte getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Char2ByteLinkedOpenCustomHashMap extends Char2ByteOpenCustomHashMap
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -191,13 +191,13 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -205,7 +205,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -225,13 +225,13 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -239,7 +239,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -260,7 +260,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -271,7 +271,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -284,7 +284,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -295,7 +295,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -306,7 +306,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -328,7 +328,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -349,7 +349,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
public char getAndMoveToFirst(char key) {
|
public char getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
public char getAndMoveToLast(char key) {
|
public char getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,8 +533,8 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -551,8 +551,8 @@ public class Char2CharLinkedOpenCustomHashMap extends Char2CharOpenCustomHashMap
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
public double getAndMoveToFirst(char key) {
|
public double getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
public double getAndMoveToLast(char key) {
|
public double getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Char2DoubleLinkedOpenCustomHashMap extends Char2DoubleOpenCustomHas
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
public float getAndMoveToFirst(char key) {
|
public float getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
public float getAndMoveToLast(char key) {
|
public float getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Char2FloatLinkedOpenCustomHashMap extends Char2FloatOpenCustomHashM
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
public int getAndMoveToFirst(char key) {
|
public int getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
public int getAndMoveToLast(char key) {
|
public int getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Char2IntLinkedOpenCustomHashMap extends Char2IntOpenCustomHashMap i
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
public long getAndMoveToFirst(char key) {
|
public long getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
public long getAndMoveToLast(char key) {
|
public long getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Char2LongLinkedOpenCustomHashMap extends Char2LongOpenCustomHashMap
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -193,13 +193,13 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -207,7 +207,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -215,7 +215,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -227,13 +227,13 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -241,7 +241,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -249,7 +249,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -262,7 +262,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -273,7 +273,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -286,7 +286,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -297,7 +297,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -308,7 +308,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -330,7 +330,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -351,7 +351,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
public V getAndMoveToFirst(char key) {
|
public V getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
public V getAndMoveToLast(char key) {
|
public V getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,8 +535,8 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -553,8 +553,8 @@ public class Char2ObjectLinkedOpenCustomHashMap<V> extends Char2ObjectOpenCustom
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastCharKey(), key)) return false;
|
||||||
if(strategy.equals(key, (char)0)) {
|
if(strategy.equals(key, (char)0)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], (char)0)) {
|
while(!strategy.equals(keys[pos], (char)0)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
public short getAndMoveToFirst(char key) {
|
public short getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
public short getAndMoveToLast(char key) {
|
public short getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Char2ShortLinkedOpenCustomHashMap extends Char2ShortOpenCustomHashM
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
public boolean getAndMoveToFirst(char key) {
|
public boolean getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
public boolean getAndMoveToLast(char key) {
|
public boolean getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Char2BooleanLinkedOpenHashMap extends Char2BooleanOpenHashMap imple
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
public byte getAndMoveToFirst(char key) {
|
public byte getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
public byte getAndMoveToLast(char key) {
|
public byte getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Char2ByteLinkedOpenHashMap extends Char2ByteOpenHashMap implements
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -168,13 +168,13 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -182,7 +182,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -202,13 +202,13 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -216,7 +216,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -237,7 +237,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -248,7 +248,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -261,7 +261,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -272,7 +272,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -283,7 +283,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -305,7 +305,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -326,7 +326,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
public char getAndMoveToFirst(char key) {
|
public char getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
public char getAndMoveToLast(char key) {
|
public char getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,8 +531,8 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -549,8 +549,8 @@ public class Char2CharLinkedOpenHashMap extends Char2CharOpenHashMap implements
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
public double getAndMoveToFirst(char key) {
|
public double getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
public double getAndMoveToLast(char key) {
|
public double getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Char2DoubleLinkedOpenHashMap extends Char2DoubleOpenHashMap impleme
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
public float getAndMoveToFirst(char key) {
|
public float getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
public float getAndMoveToLast(char key) {
|
public float getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Char2FloatLinkedOpenHashMap extends Char2FloatOpenHashMap implement
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
public int getAndMoveToFirst(char key) {
|
public int getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
public int getAndMoveToLast(char key) {
|
public int getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Char2IntLinkedOpenHashMap extends Char2IntOpenHashMap implements Ch
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
public long getAndMoveToFirst(char key) {
|
public long getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
public long getAndMoveToLast(char key) {
|
public long getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Char2LongLinkedOpenHashMap extends Char2LongOpenHashMap implements
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -170,13 +170,13 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -184,7 +184,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -192,7 +192,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -204,13 +204,13 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -218,7 +218,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -226,7 +226,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -239,7 +239,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -250,7 +250,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -263,7 +263,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -274,7 +274,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -285,7 +285,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -307,7 +307,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -328,7 +328,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
public V getAndMoveToFirst(char key) {
|
public V getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
public V getAndMoveToLast(char key) {
|
public V getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,8 +522,8 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -540,8 +540,8 @@ public class Char2ObjectLinkedOpenHashMap<V> extends Char2ObjectOpenHashMap<V> i
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
if(isEmpty() || firstCharKey() == key) return false;
|
if(isEmpty() || firstCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
if(isEmpty() || lastCharKey() == key) return false;
|
if(isEmpty() || lastCharKey() == key) return false;
|
||||||
if(key == (char)0) {
|
if(key == (char)0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Character.hashCode(key)) & mask;
|
||||||
while(keys[pos] != (char)0) {
|
while(keys[pos] != (char)0) {
|
||||||
if(keys[pos] == key) {
|
if(keys[pos] == key) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
public short getAndMoveToFirst(char key) {
|
public short getAndMoveToFirst(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
public short getAndMoveToLast(char key) {
|
public short getAndMoveToLast(char key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Char2ShortLinkedOpenHashMap extends Char2ShortOpenHashMap implement
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -174,7 +174,6 @@ public class CharArrayPriorityQueue extends AbstractCharPriorityQueue
|
|||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(char e) {
|
public void enqueue(char e) {
|
||||||
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(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));
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class CharArraySet extends AbstractCharSet implements CharOrderedSet
|
|||||||
* @param array the array that should be used for set.
|
* @param array the array that should be used for set.
|
||||||
*/
|
*/
|
||||||
public CharArraySet(char[] array) {
|
public CharArraySet(char[] array) {
|
||||||
this(array, array.length);
|
this(array, 0, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,6 +69,18 @@ public class CharArraySet extends AbstractCharSet implements CharOrderedSet
|
|||||||
addAll(array, length);
|
addAll(array, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructur using initial Array
|
||||||
|
* @param array the array that should be used for set.
|
||||||
|
* @param offset the starting offset of where the array should be copied from
|
||||||
|
* @param length the amount of elements present within the array
|
||||||
|
* @throws NegativeArraySizeException if the length is negative
|
||||||
|
*/
|
||||||
|
public CharArraySet(char[] array, int offset, int length) {
|
||||||
|
this(length);
|
||||||
|
addAll(array, offset, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
||||||
* @param c the elements that should be added to the set.
|
* @param c the elements that should be added to the set.
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import speiger.src.collections.chars.functions.OptionalChar;
|
||||||
|
|
||||||
import speiger.src.collections.chars.functions.CharConsumer;
|
import speiger.src.collections.chars.functions.CharConsumer;
|
||||||
import speiger.src.collections.chars.functions.CharComparator;
|
import speiger.src.collections.chars.functions.CharComparator;
|
||||||
@ -210,9 +211,8 @@ public class CharAsyncBuilder
|
|||||||
* @param operator that reduces the elements.
|
* @param operator that reduces the elements.
|
||||||
* @return self with the reduce action applied
|
* @return self with the reduce action applied
|
||||||
*/
|
*/
|
||||||
public CharAsyncBuilder reduce(CharCharUnaryOperator operator) {
|
public ObjectAsyncBuilder<OptionalChar> reduce(CharCharUnaryOperator operator) {
|
||||||
task = new SimpleReduceTask(iterable.iterator(), operator);
|
return new ObjectAsyncBuilder<>(new SimpleReduceTask(iterable.iterator(), operator));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,9 +292,8 @@ public class CharAsyncBuilder
|
|||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
* @return self with the findFirst function applied
|
* @return self with the findFirst function applied
|
||||||
*/
|
*/
|
||||||
public CharAsyncBuilder findFirst(CharPredicate filter) {
|
public ObjectAsyncBuilder<OptionalChar> findFirst(CharPredicate filter) {
|
||||||
task = new FindFirstTask(iterable.iterator(), filter);
|
return new ObjectAsyncBuilder<>(new FindFirstTask(iterable.iterator(), filter));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -404,7 +403,7 @@ public class CharAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SimpleReduceTask extends BaseCharTask
|
private static class SimpleReduceTask extends BaseObjectTask<OptionalChar>
|
||||||
{
|
{
|
||||||
CharIterator iter;
|
CharIterator iter;
|
||||||
CharCharUnaryOperator operator;
|
CharCharUnaryOperator operator;
|
||||||
@ -414,6 +413,7 @@ public class CharAsyncBuilder
|
|||||||
public SimpleReduceTask(CharIterator iter, CharCharUnaryOperator operator) {
|
public SimpleReduceTask(CharIterator iter, CharCharUnaryOperator operator) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
|
this.setResult(OptionalChar.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -428,7 +428,7 @@ public class CharAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!iter.hasNext()) {
|
if(!iter.hasNext()) {
|
||||||
setResult(value);
|
setResult(OptionalChar.of(value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -498,7 +498,7 @@ public class CharAsyncBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FindFirstTask extends BaseCharTask
|
private static class FindFirstTask extends BaseObjectTask<OptionalChar>
|
||||||
{
|
{
|
||||||
CharIterator iter;
|
CharIterator iter;
|
||||||
CharPredicate filter;
|
CharPredicate filter;
|
||||||
@ -506,6 +506,7 @@ public class CharAsyncBuilder
|
|||||||
public FindFirstTask(CharIterator iter, CharPredicate filter) {
|
public FindFirstTask(CharIterator iter, CharPredicate filter) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
this.setResult(OptionalChar.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -513,7 +514,7 @@ public class CharAsyncBuilder
|
|||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
char entry = iter.nextChar();
|
char entry = iter.nextChar();
|
||||||
if(filter.test(iter.nextChar())) {
|
if(filter.test(iter.nextChar())) {
|
||||||
setResult(entry);
|
setResult(OptionalChar.of(entry));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,7 +109,10 @@ public class CharCollections
|
|||||||
return new SingletonCollection(element);
|
return new SingletonCollection(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static CollectionWrapper wrapper() {
|
/**
|
||||||
|
* Internal Use mainly. Its a collection wrapper with 0 dependencies for those actions where a collector is needed.
|
||||||
|
*/
|
||||||
|
public static CollectionWrapper wrapper() {
|
||||||
return new CollectionWrapper();
|
return new CollectionWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import java.util.Iterator;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -112,6 +113,14 @@ public class CopyOnWriteDoubleArrayList extends AbstractDoubleList implements IT
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a CopyOnWriteArrayList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static CopyOnWriteDoubleArrayList toList(DoubleStream stream) {
|
||||||
|
return stream.collect(CopyOnWriteDoubleArrayList::new, CopyOnWriteDoubleArrayList::add, CopyOnWriteDoubleArrayList::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
private void setArray(double[] data) {
|
private void setArray(double[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
|
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
@ -144,6 +146,15 @@ public class DoubleArrayList extends AbstractDoubleList implements IDoubleArray,
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleArrayList toList(DoubleStream stream) {
|
||||||
|
return stream.collect(DoubleArrayList::new, DoubleArrayList::add, DoubleArrayList::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the specified element to the end of this list.
|
* Appends the specified element to the end of this list.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
import java.util.Spliterator.OfDouble;
|
import java.util.Spliterator.OfDouble;
|
||||||
@ -103,6 +104,15 @@ public class DoubleLinkedList extends AbstractDoubleList implements DoublePriori
|
|||||||
for(int i = offset,m=offset+length;i<m;add(a[i++]));
|
for(int i = offset,m=offset+length;i<m;add(a[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleLinkedList toList(DoubleStream stream) {
|
||||||
|
return stream.collect(DoubleLinkedList::new, DoubleLinkedList::add, DoubleLinkedList::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(double e) {
|
public boolean add(double e) {
|
||||||
add(size(), e);
|
add(size(), e);
|
||||||
|
|||||||
@ -1,13 +1,18 @@
|
|||||||
package speiger.src.collections.doubles.lists;
|
package speiger.src.collections.doubles.lists;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import speiger.src.collections.doubles.utils.DoubleCollections;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
import java.util.function.DoubleUnaryOperator;
|
import java.util.function.DoubleUnaryOperator;
|
||||||
|
|
||||||
import speiger.src.collections.doubles.collections.DoubleCollection;
|
import speiger.src.collections.doubles.collections.DoubleCollection;
|
||||||
@ -18,8 +23,6 @@ import speiger.src.collections.objects.functions.consumer.ObjectDoubleConsumer;
|
|||||||
import speiger.src.collections.doubles.functions.function.DoubleDoubleUnaryOperator;
|
import speiger.src.collections.doubles.functions.function.DoubleDoubleUnaryOperator;
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.doubles.utils.DoubleIterators;
|
import speiger.src.collections.doubles.utils.DoubleIterators;
|
||||||
import java.util.stream.DoubleStream;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
import speiger.src.collections.doubles.collections.DoubleSplititerator;
|
import speiger.src.collections.doubles.collections.DoubleSplititerator;
|
||||||
import speiger.src.collections.doubles.utils.DoubleSplititerators;
|
import speiger.src.collections.doubles.utils.DoubleSplititerators;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
@ -89,6 +92,15 @@ public class ImmutableDoubleList extends AbstractDoubleList
|
|||||||
data = Arrays.copyOfRange(a, offset, offset+length);
|
data = Arrays.copyOfRange(a, offset, offset+length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ImmutableList
|
||||||
|
* @return a list with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static ImmutableDoubleList toList(DoubleStream stream) {
|
||||||
|
return new ImmutableDoubleList(stream.collect((Supplier<DoubleCollection>)DoubleCollections::wrapper, DoubleCollection::add, DoubleCollection::addAll).toDoubleArray());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(double e) { throw new UnsupportedOperationException(); }
|
public boolean add(double e) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
public boolean getAndMoveToFirst(double key) {
|
public boolean getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
public boolean getAndMoveToLast(double key) {
|
public boolean getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Double2BooleanLinkedOpenCustomHashMap extends Double2BooleanOpenCus
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
public byte getAndMoveToFirst(double key) {
|
public byte getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
public byte getAndMoveToLast(double key) {
|
public byte getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Double2ByteLinkedOpenCustomHashMap extends Double2ByteOpenCustomHas
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
public char getAndMoveToFirst(double key) {
|
public char getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
public char getAndMoveToLast(double key) {
|
public char getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Double2CharLinkedOpenCustomHashMap extends Double2CharOpenCustomHas
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -191,13 +191,13 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -205,7 +205,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -225,13 +225,13 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -239,7 +239,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -260,7 +260,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -271,7 +271,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -284,7 +284,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -295,7 +295,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -306,7 +306,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -328,7 +328,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -349,7 +349,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
public double getAndMoveToFirst(double key) {
|
public double getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
public double getAndMoveToLast(double key) {
|
public double getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,8 +533,8 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -551,8 +551,8 @@ public class Double2DoubleLinkedOpenCustomHashMap extends Double2DoubleOpenCusto
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
public float getAndMoveToFirst(double key) {
|
public float getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
public float getAndMoveToLast(double key) {
|
public float getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Double2FloatLinkedOpenCustomHashMap extends Double2FloatOpenCustomH
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
public int getAndMoveToFirst(double key) {
|
public int getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
public int getAndMoveToLast(double key) {
|
public int getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Double2IntLinkedOpenCustomHashMap extends Double2IntOpenCustomHashM
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
public long getAndMoveToFirst(double key) {
|
public long getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
public long getAndMoveToLast(double key) {
|
public long getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Double2LongLinkedOpenCustomHashMap extends Double2LongOpenCustomHas
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -193,13 +193,13 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -207,7 +207,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -215,7 +215,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -227,13 +227,13 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -241,7 +241,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -249,7 +249,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -262,7 +262,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -273,7 +273,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -286,7 +286,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -297,7 +297,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -308,7 +308,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -330,7 +330,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -351,7 +351,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
public V getAndMoveToFirst(double key) {
|
public V getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
public V getAndMoveToLast(double key) {
|
public V getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,8 +535,8 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -553,8 +553,8 @@ public class Double2ObjectLinkedOpenCustomHashMap<V> extends Double2ObjectOpenCu
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -199,13 +199,13 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -213,7 +213,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -221,7 +221,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -233,13 +233,13 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -247,7 +247,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -255,7 +255,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -268,7 +268,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -279,7 +279,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -292,7 +292,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@ -303,7 +303,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -314,7 +314,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(firstDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -336,7 +336,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
if(isEmpty() || strategy.equals(lastDoubleKey(), key)) return false;
|
||||||
if(strategy.equals(key, 0D)) {
|
if(strategy.equals(key, 0D)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], 0D)) {
|
while(!strategy.equals(keys[pos], 0D)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -357,7 +357,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
public short getAndMoveToFirst(double key) {
|
public short getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
public short getAndMoveToLast(double key) {
|
public short getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -559,8 +559,8 @@ public class Double2ShortLinkedOpenCustomHashMap extends Double2ShortOpenCustomH
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
boolean lastValue = values[nullIndex];
|
boolean lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
boolean lastValue = values[pos];
|
boolean lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
public boolean getAndMoveToFirst(double key) {
|
public boolean getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
public boolean getAndMoveToLast(double key) {
|
public boolean getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Double2BooleanLinkedOpenHashMap extends Double2BooleanOpenHashMap i
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
byte lastValue = values[nullIndex];
|
byte lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
byte lastValue = values[pos];
|
byte lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
public byte getAndMoveToFirst(double key) {
|
public byte getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
public byte getAndMoveToLast(double key) {
|
public byte getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Double2ByteLinkedOpenHashMap extends Double2ByteOpenHashMap impleme
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
char lastValue = values[nullIndex];
|
char lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
char lastValue = values[pos];
|
char lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
public char getAndMoveToFirst(double key) {
|
public char getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
public char getAndMoveToLast(double key) {
|
public char getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Double2CharLinkedOpenHashMap extends Double2CharOpenHashMap impleme
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -168,13 +168,13 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -182,7 +182,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -202,13 +202,13 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
double lastValue = values[nullIndex];
|
double lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -216,7 +216,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
double lastValue = values[pos];
|
double lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -237,7 +237,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -248,7 +248,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -261,7 +261,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -272,7 +272,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -283,7 +283,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -305,7 +305,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -326,7 +326,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
public double getAndMoveToFirst(double key) {
|
public double getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
public double getAndMoveToLast(double key) {
|
public double getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,8 +531,8 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -549,8 +549,8 @@ public class Double2DoubleLinkedOpenHashMap extends Double2DoubleOpenHashMap imp
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
float lastValue = values[nullIndex];
|
float lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
float lastValue = values[pos];
|
float lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
public float getAndMoveToFirst(double key) {
|
public float getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
public float getAndMoveToLast(double key) {
|
public float getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Double2FloatLinkedOpenHashMap extends Double2FloatOpenHashMap imple
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
int lastValue = values[nullIndex];
|
int lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
int lastValue = values[pos];
|
int lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
public int getAndMoveToFirst(double key) {
|
public int getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
public int getAndMoveToLast(double key) {
|
public int getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Double2IntLinkedOpenHashMap extends Double2IntOpenHashMap implement
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
long lastValue = values[nullIndex];
|
long lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
long lastValue = values[pos];
|
long lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
public long getAndMoveToFirst(double key) {
|
public long getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
public long getAndMoveToLast(double key) {
|
public long getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Double2LongLinkedOpenHashMap extends Double2LongOpenHashMap impleme
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -170,13 +170,13 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -184,7 +184,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -192,7 +192,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -204,13 +204,13 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
V lastValue = values[nullIndex];
|
V lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -218,7 +218,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
V lastValue = values[pos];
|
V lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -226,7 +226,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -239,7 +239,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -250,7 +250,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -263,7 +263,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -274,7 +274,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -285,7 +285,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -307,7 +307,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -328,7 +328,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
public V getAndMoveToFirst(double key) {
|
public V getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
public V getAndMoveToLast(double key) {
|
public V getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,8 +522,8 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -540,8 +540,8 @@ public class Double2ObjectLinkedOpenHashMap<V> extends Double2ObjectOpenHashMap<
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -176,13 +176,13 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -190,7 +190,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -198,7 +198,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -210,13 +210,13 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
short lastValue = values[nullIndex];
|
short lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -224,7 +224,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
short lastValue = values[pos];
|
short lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -232,7 +232,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -245,7 +245,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -256,7 +256,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -269,7 +269,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
@ -280,7 +280,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, true);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@ -291,7 +291,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(firstDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToFirstIndex(pos);
|
moveToFirstIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -313,7 +313,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
if(isEmpty() || Double.doubleToLongBits(lastDoubleKey()) == Double.doubleToLongBits(key)) return false;
|
||||||
if(Double.doubleToLongBits(key) == 0) {
|
if(Double.doubleToLongBits(key) == 0) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
int pos = HashUtil.mix(Double.hashCode(key)) & mask;
|
||||||
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
while(Double.doubleToLongBits(keys[pos]) != 0) {
|
||||||
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
if(Double.doubleToLongBits(keys[pos]) == Double.doubleToLongBits(key)) {
|
||||||
moveToLastIndex(pos);
|
moveToLastIndex(pos, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@ -334,7 +334,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
public short getAndMoveToFirst(double key) {
|
public short getAndMoveToFirst(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
public short getAndMoveToLast(double key) {
|
public short getAndMoveToLast(double key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index, false);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +539,8 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos) {
|
protected void moveToFirstIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || firstIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@ -557,8 +557,8 @@ public class Double2ShortLinkedOpenHashMap extends Double2ShortOpenHashMap imple
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos) {
|
protected void moveToLastIndex(int startPos, boolean adding) {
|
||||||
if(size == 1 || lastIndex == startPos) return;
|
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package speiger.src.collections.doubles.queues;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
@ -87,6 +88,20 @@ public class DoubleArrayFIFOQueue extends AbstractDoublePriorityQueue implements
|
|||||||
this(MIN_CAPACITY);
|
this(MIN_CAPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayFIFOQueue
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleArrayFIFOQueue toQueue(DoubleStream stream) {
|
||||||
|
return stream.collect(DoubleArrayFIFOQueue::new, DoubleArrayFIFOQueue::enqueue, DoubleArrayFIFOQueue::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DoubleArrayFIFOQueue merge(DoubleArrayFIFOQueue a) {
|
||||||
|
enqueueAll(a.toDoubleArray());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DoubleIterator iterator() {
|
public DoubleIterator iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
import speiger.src.collections.doubles.collections.DoubleCollection;
|
import speiger.src.collections.doubles.collections.DoubleCollection;
|
||||||
@ -175,6 +176,19 @@ public class DoubleArrayPriorityQueue extends AbstractDoublePriorityQueue
|
|||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayPriorityQueue
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleArrayPriorityQueue toQueue(DoubleStream stream) {
|
||||||
|
return stream.collect(DoubleArrayPriorityQueue::new, DoubleArrayPriorityQueue::enqueue, DoubleArrayPriorityQueue::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DoubleArrayPriorityQueue merge(DoubleArrayPriorityQueue a) {
|
||||||
|
enqueueAll(a.toDoubleArray());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(double e) {
|
public void enqueue(double e) {
|
||||||
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(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));
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
import speiger.src.collections.doubles.collections.DoubleCollection;
|
import speiger.src.collections.doubles.collections.DoubleCollection;
|
||||||
@ -177,6 +178,20 @@ public class DoubleHeapPriorityQueue extends AbstractDoublePriorityQueue
|
|||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArrayFIFOQueue
|
||||||
|
* @return a queue with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleHeapPriorityQueue toQueue(DoubleStream stream) {
|
||||||
|
return stream.collect(DoubleHeapPriorityQueue::new, DoubleHeapPriorityQueue::enqueue, DoubleHeapPriorityQueue::merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DoubleHeapPriorityQueue merge(DoubleHeapPriorityQueue a) {
|
||||||
|
enqueueAll(a.toDoubleArray());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import java.util.Iterator;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
import speiger.src.collections.doubles.collections.DoubleBidirectionalIterator;
|
import speiger.src.collections.doubles.collections.DoubleBidirectionalIterator;
|
||||||
@ -183,6 +184,15 @@ public class DoubleAVLTreeSet extends AbstractDoubleSet implements DoubleNavigab
|
|||||||
while(iterator.hasNext()) add(iterator.nextDouble());
|
while(iterator.hasNext()) add(iterator.nextDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a AVLTreeSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleAVLTreeSet toSet(DoubleStream stream) {
|
||||||
|
return stream.collect(DoubleAVLTreeSet::new, DoubleAVLTreeSet::add, DoubleAVLTreeSet::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(double value) { defaultMaxNotFound = value; }
|
public void setDefaultMaxValue(double value) { defaultMaxNotFound = value; }
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
import speiger.src.collections.doubles.collections.DoubleBidirectionalIterator;
|
import speiger.src.collections.doubles.collections.DoubleBidirectionalIterator;
|
||||||
@ -54,7 +55,7 @@ public class DoubleArraySet extends AbstractDoubleSet implements DoubleOrderedSe
|
|||||||
* @param array the array that should be used for set.
|
* @param array the array that should be used for set.
|
||||||
*/
|
*/
|
||||||
public DoubleArraySet(double[] array) {
|
public DoubleArraySet(double[] array) {
|
||||||
this(array, array.length);
|
this(array, 0, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,6 +69,18 @@ public class DoubleArraySet extends AbstractDoubleSet implements DoubleOrderedSe
|
|||||||
addAll(array, length);
|
addAll(array, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructur using initial Array
|
||||||
|
* @param array the array that should be used for set.
|
||||||
|
* @param offset the starting offset of where the array should be copied from
|
||||||
|
* @param length the amount of elements present within the array
|
||||||
|
* @throws NegativeArraySizeException if the length is negative
|
||||||
|
*/
|
||||||
|
public DoubleArraySet(double[] array, int offset, int length) {
|
||||||
|
this(length);
|
||||||
|
addAll(array, offset, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
||||||
* @param c the elements that should be added to the set.
|
* @param c the elements that should be added to the set.
|
||||||
@ -111,6 +124,15 @@ public class DoubleArraySet extends AbstractDoubleSet implements DoubleOrderedSe
|
|||||||
for(DoubleIterator iter = s.iterator();iter.hasNext();data[size++] = iter.nextDouble());
|
for(DoubleIterator iter = s.iterator();iter.hasNext();data[size++] = iter.nextDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a ArraySet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleArraySet toList(DoubleStream stream) {
|
||||||
|
return stream.collect(DoubleArraySet::new, DoubleArraySet::add, DoubleArraySet::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(double o) {
|
public boolean add(double o) {
|
||||||
int index = findIndex(o);
|
int index = findIndex(o);
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
import java.util.function.DoublePredicate;
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
import speiger.src.collections.doubles.collections.DoubleCollection;
|
import speiger.src.collections.doubles.collections.DoubleCollection;
|
||||||
@ -215,6 +216,15 @@ public class DoubleLinkedOpenCustomHashSet extends DoubleOpenCustomHashSet imple
|
|||||||
while(iterator.hasNext()) add(iterator.nextDouble());
|
while(iterator.hasNext()) add(iterator.nextDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects a Stream to a LinkedCustomHashSet
|
||||||
|
* @return a set with the contents of the Stream
|
||||||
|
*/
|
||||||
|
public static DoubleLinkedOpenCustomHashSet toList(DoubleStream stream, DoubleStrategy strategy) {
|
||||||
|
return stream.collect(() -> new DoubleLinkedOpenCustomHashSet(strategy), DoubleLinkedOpenCustomHashSet::add, DoubleLinkedOpenCustomHashSet::addAll);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(double o) {
|
public void addFirst(double o) {
|
||||||
if(strategy.equals(o, 0D)) {
|
if(strategy.equals(o, 0D)) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user