renamed MathUtils -> MathUtil
This commit is contained in:
parent
12f5e9c0ed
commit
5758e66ca8
@ -19,7 +19,7 @@ package dorkbox.util;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public
|
public
|
||||||
class MathUtils {
|
class MathUtil {
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
@ -19,7 +19,7 @@
|
|||||||
package dorkbox.util.collections;
|
package dorkbox.util.collections;
|
||||||
|
|
||||||
|
|
||||||
import dorkbox.util.MathUtils;
|
import dorkbox.util.MathUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ public class IntArray {
|
|||||||
|
|
||||||
public void shuffle () {
|
public void shuffle () {
|
||||||
for (int i = this.size - 1; i >= 0; i--) {
|
for (int i = this.size - 1; i >= 0; i--) {
|
||||||
int ii = MathUtils.randomInt(i);
|
int ii = MathUtil.randomInt(i);
|
||||||
int temp = this.items[i];
|
int temp = this.items[i];
|
||||||
this.items[i] = this.items[ii];
|
this.items[i] = this.items[ii];
|
||||||
this.items[ii] = temp;
|
this.items[ii] = temp;
|
||||||
@ -311,7 +311,7 @@ public class IntArray {
|
|||||||
if (this.size == 0) {
|
if (this.size == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return this.items[MathUtils.randomInt(0, this.size - 1)];
|
return this.items[MathUtil.randomInt(0, this.size - 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] toArray () {
|
public int[] toArray () {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package dorkbox.util.collections;
|
package dorkbox.util.collections;
|
||||||
|
|
||||||
|
|
||||||
import dorkbox.util.MathUtils;
|
import dorkbox.util.MathUtil;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@ -78,7 +78,7 @@ public class IntMap<V> {
|
|||||||
if (this.capacity > 1 << 30) {
|
if (this.capacity > 1 << 30) {
|
||||||
throw new IllegalArgumentException("initialCapacity is too large: " + initialCapacity);
|
throw new IllegalArgumentException("initialCapacity is too large: " + initialCapacity);
|
||||||
}
|
}
|
||||||
this.capacity = MathUtils.nextPowerOfTwo(initialCapacity);
|
this.capacity = MathUtil.nextPowerOfTwo(initialCapacity);
|
||||||
|
|
||||||
if (loadFactor <= 0) {
|
if (loadFactor <= 0) {
|
||||||
throw new IllegalArgumentException("loadFactor must be > 0: " + loadFactor);
|
throw new IllegalArgumentException("loadFactor must be > 0: " + loadFactor);
|
||||||
@ -237,7 +237,7 @@ public class IntMap<V> {
|
|||||||
int i = 0, pushIterations = this.pushIterations;
|
int i = 0, pushIterations = this.pushIterations;
|
||||||
do {
|
do {
|
||||||
// Replace the key and value for one of the hashes.
|
// Replace the key and value for one of the hashes.
|
||||||
switch (MathUtils.randomInt(2)) {
|
switch (MathUtil.randomInt(2)) {
|
||||||
case 0:
|
case 0:
|
||||||
evictedKey = key1;
|
evictedKey = key1;
|
||||||
evictedValue = valueTable[index1];
|
evictedValue = valueTable[index1];
|
||||||
@ -557,7 +557,7 @@ public class IntMap<V> {
|
|||||||
public void ensureCapacity (int additionalCapacity) {
|
public void ensureCapacity (int additionalCapacity) {
|
||||||
int sizeNeeded = this.size + additionalCapacity;
|
int sizeNeeded = this.size + additionalCapacity;
|
||||||
if (sizeNeeded >= this.threshold) {
|
if (sizeNeeded >= this.threshold) {
|
||||||
resize(MathUtils.nextPowerOfTwo((int)(sizeNeeded / this.loadFactor)));
|
resize(MathUtil.nextPowerOfTwo((int) (sizeNeeded / this.loadFactor)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
package dorkbox.util.collections;
|
package dorkbox.util.collections;
|
||||||
|
|
||||||
import com.esotericsoftware.kryo.util.ObjectMap;
|
import com.esotericsoftware.kryo.util.ObjectMap;
|
||||||
import dorkbox.util.MathUtils;
|
import dorkbox.util.MathUtil;
|
||||||
|
|
||||||
/** An unordered map where the values are ints. This implementation is a cuckoo hash map using 3 hashes, random walking, and a
|
/** An unordered map where the values are ints. This implementation is a cuckoo hash map using 3 hashes, random walking, and a
|
||||||
* small stash for problematic keys. Null keys are not allowed. No allocation is done except when growing the table size. <br>
|
* small stash for problematic keys. Null keys are not allowed. No allocation is done except when growing the table size. <br>
|
||||||
@ -209,7 +209,7 @@ public class ObjectIntMap<K> {
|
|||||||
int i = 0, pushIterations = this.pushIterations;
|
int i = 0, pushIterations = this.pushIterations;
|
||||||
do {
|
do {
|
||||||
// Replace the key and value for one of the hashes.
|
// Replace the key and value for one of the hashes.
|
||||||
switch (MathUtils.randomInt(2)) {
|
switch (MathUtil.randomInt(2)) {
|
||||||
case 0:
|
case 0:
|
||||||
evictedKey = key1;
|
evictedKey = key1;
|
||||||
evictedValue = valueTable[index1];
|
evictedValue = valueTable[index1];
|
||||||
|
Loading…
Reference in New Issue
Block a user