Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
4 changes: 2 additions & 2 deletions src/com/badlogic/gdx/physics/box2d/joints/PulleyJointDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/** Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, max lengths for each side, and a
* pulley ratio. */
public class PulleyJointDef extends JointDef {
private final static float minPulleyLength = 2.0f;
//private final static float minPulleyLength = 2.0f;

public PulleyJointDef () {
type = JointType.PulleyJoint;
Expand All @@ -42,7 +42,7 @@ public void initialize (Body bodyA, Body bodyB, Vector2 groundAnchorA, Vector2 g
lengthA = anchorA.dst(groundAnchorA);
lengthB = anchorB.dst(groundAnchorB);
this.ratio = ratio;
float C = lengthA + ratio * lengthB;
//float C = lengthA + ratio * lengthB;
}

/** The first ground anchor in world coordinates. This point never moves. */
Expand Down
15 changes: 8 additions & 7 deletions src/com/badlogic/gdx/utils/Array.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/** A resizable, ordered or unordered array of objects. If unordered, this class avoids a memory copy when removing elements (the
* last element is moved to the removed element's position).
* @author Nathan Sweet */
@SuppressWarnings("unchecked")
public class Array<T> implements Iterable<T> {
/** Provides direct access to the underlying array. If the Array's generic type is not Object, this field may only be accessed
* if the {@link Array#Array(boolean, int, Class)} constructor was used. */
Expand All @@ -33,7 +34,7 @@ public class Array<T> implements Iterable<T> {
public int size;
public boolean ordered;

private ArrayIterator iterator;
private ArrayIterator<T> iterator;

/** Creates an ordered array with a capacity of 16. */
public Array () {
Expand Down Expand Up @@ -70,7 +71,7 @@ public Array (Class<T> arrayType) {
/** Creates a new array containing the elements in the specified array. The new array will have the same type of backing array
* and will be ordered if the specified array is ordered. The capacity is set to the number of elements, so any subsequent
* elements added will cause the backing array to be grown. */
public Array (Array array) {
public Array (Array<T> array) {
this(array.ordered, array.size, (Class<T>)array.items.getClass().getComponentType());
size = array.size;
System.arraycopy(array.items, 0, items, 0, size);
Expand All @@ -88,7 +89,7 @@ public Array (T[] array) {
* @param ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a
* memory copy. */
public Array (boolean ordered, T[] array) {
this(ordered, array.length, (Class)array.getClass().getComponentType());
this(ordered, array.length, (Class<T>)array.getClass().getComponentType());
size = array.length;
System.arraycopy(array, 0, items, 0, size);
}
Expand All @@ -99,11 +100,11 @@ public void add (T value) {
items[size++] = value;
}

public void addAll (Array array) {
public void addAll (Array<T> array) {
addAll(array, 0, array.size);
}

public void addAll (Array array, int offset, int length) {
public void addAll (Array<T> array, int offset, int length) {
if (offset + length > array.size)
throw new IllegalArgumentException("offset + length must be <= size: " + offset + " + " + length + " <= " + array.size);
addAll((T[])array.items, offset, length);
Expand Down Expand Up @@ -305,7 +306,7 @@ public void shuffle () {
* time this method is called. Use the {@link ArrayIterator} constructor for nested or multithreaded iteration. */
public Iterator<T> iterator () {
if (iterator == null)
iterator = new ArrayIterator(this);
iterator = new ArrayIterator<T>(this);
else
iterator.index = 0;
return iterator;
Expand Down Expand Up @@ -339,7 +340,7 @@ public <V> V[] toArray (Class<V> type) {
public boolean equals (Object object) {
if (object == this) return true;
if (!(object instanceof Array)) return false;
Array array = (Array)object;
Array<T> array = (Array<T>)object;
int n = size;
if (n != array.size) return false;
Object[] items1 = this.items;
Expand Down
20 changes: 10 additions & 10 deletions src/com/badlogic/gdx/utils/ComparableTimSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private static void binarySort (Object[] a, int lo, int hi, int start) {
if (start == lo) start++;
for (; start < hi; start++) {
@SuppressWarnings("unchecked")
Comparable<Object> pivot = (Comparable)a[start];
Comparable<Object> pivot = (Comparable<Object>)a[start];

// Set left (and right) to the index where a[start] (pivot) belongs
int left = lo;
Expand Down Expand Up @@ -269,12 +269,12 @@ private static int countRunAndMakeAscending (Object[] a, int lo, int hi) {
if (runHi == hi) return 1;

// Find end of run, and reverse range if descending
if (((Comparable)a[runHi++]).compareTo(a[lo]) < 0) { // Descending
while (runHi < hi && ((Comparable)a[runHi]).compareTo(a[runHi - 1]) < 0)
if (((Comparable<Object>)a[runHi++]).compareTo(a[lo]) < 0) { // Descending
while (runHi < hi && ((Comparable<Object>)a[runHi]).compareTo(a[runHi - 1]) < 0)
runHi++;
reverseRange(a, lo, runHi);
} else { // Ascending
while (runHi < hi && ((Comparable)a[runHi]).compareTo(a[runHi - 1]) >= 0)
while (runHi < hi && ((Comparable<Object>)a[runHi]).compareTo(a[runHi - 1]) >= 0)
runHi++;
}

Expand Down Expand Up @@ -587,7 +587,7 @@ private void mergeLo (int base1, int len1, int base2, int len2) {
*/
do {
if (DEBUG) assert len1 > 1 && len2 > 0;
if (((Comparable)a[cursor2]).compareTo(tmp[cursor1]) < 0) {
if (((Comparable<Object>)a[cursor2]).compareTo(tmp[cursor1]) < 0) {
a[dest++] = a[cursor2++];
count2++;
count1 = 0;
Expand All @@ -606,7 +606,7 @@ private void mergeLo (int base1, int len1, int base2, int len2) {
*/
do {
if (DEBUG) assert len1 > 1 && len2 > 0;
count1 = gallopRight((Comparable)a[cursor2], tmp, cursor1, len1, 0);
count1 = gallopRight((Comparable<Object>)a[cursor2], tmp, cursor1, len1, 0);
if (count1 != 0) {
System.arraycopy(tmp, cursor1, a, dest, count1);
dest += count1;
Expand All @@ -618,7 +618,7 @@ private void mergeLo (int base1, int len1, int base2, int len2) {
a[dest++] = a[cursor2++];
if (--len2 == 0) break outer;

count2 = gallopLeft((Comparable)tmp[cursor1], a, cursor2, len2, 0);
count2 = gallopLeft((Comparable<Object>)tmp[cursor1], a, cursor2, len2, 0);
if (count2 != 0) {
System.arraycopy(a, cursor2, a, dest, count2);
dest += count2;
Expand Down Expand Up @@ -693,7 +693,7 @@ private void mergeHi (int base1, int len1, int base2, int len2) {
*/
do {
if (DEBUG) assert len1 > 0 && len2 > 1;
if (((Comparable)tmp[cursor2]).compareTo(a[cursor1]) < 0) {
if (((Comparable<Object>)tmp[cursor2]).compareTo(a[cursor1]) < 0) {
a[dest--] = a[cursor1--];
count1++;
count2 = 0;
Expand All @@ -712,7 +712,7 @@ private void mergeHi (int base1, int len1, int base2, int len2) {
*/
do {
if (DEBUG) assert len1 > 0 && len2 > 1;
count1 = len1 - gallopRight((Comparable)tmp[cursor2], a, base1, len1, len1 - 1);
count1 = len1 - gallopRight((Comparable<Object>)tmp[cursor2], a, base1, len1, len1 - 1);
if (count1 != 0) {
dest -= count1;
cursor1 -= count1;
Expand All @@ -723,7 +723,7 @@ private void mergeHi (int base1, int len1, int base2, int len2) {
a[dest--] = tmp[cursor2--];
if (--len2 == 1) break outer;

count2 = len2 - gallopLeft((Comparable)a[cursor1], tmp, 0, len2, len2 - 1);
count2 = len2 - gallopLeft((Comparable<Object>)a[cursor1], tmp, 0, len2, len2 - 1);
if (count2 != 0) {
dest -= count2;
cursor2 -= count2;
Expand Down
27 changes: 14 additions & 13 deletions src/com/badlogic/gdx/utils/LongMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
* depending on hash collisions. Load factors greater than 0.91 greatly increase the chances the map will have to rehash to the
* next higher POT size.
* @author Nathan Sweet */
@SuppressWarnings("unchecked")
public class LongMap<V> {
private static final int PRIME1 = 0xbe1f14b1;
//private static final int PRIME1 = 0xbe1f14b1;
private static final int PRIME2 = 0xb4b82e39;
private static final int PRIME3 = 0xced1c241;
private static final int EMPTY = 0;
Expand All @@ -47,9 +48,9 @@ public class LongMap<V> {
private int stashCapacity;
private int pushIterations;

private Entries entries;
private Values values;
private Keys keys;
private Entries<V> entries;
private Values<V> values;
private Keys<V> keys;

/** Creates a new map with an initial capacity of 32 and a load factor of 0.8. This map will hold 25 items before growing the
* backing table. */
Expand Down Expand Up @@ -531,7 +532,7 @@ public String toString () {
* time this method is called. Use the {@link Entries} constructor for nested or multithreaded iteration. */
public Entries<V> entries () {
if (entries == null)
entries = new Entries(this);
entries = new Entries<V>(this);
else
entries.reset();
return entries;
Expand All @@ -541,17 +542,17 @@ public Entries<V> entries () {
* time this method is called. Use the {@link Entries} constructor for nested or multithreaded iteration. */
public Values<V> values () {
if (values == null)
values = new Values(this);
values = new Values<V>(this);
else
values.reset();
return values;
}

/** Returns an iterator for the keys in the map. Remove is supported. Note that the same iterator instance is returned each time
* this method is called. Use the {@link Entries} constructor for nested or multithreaded iteration. */
public Keys keys () {
public Keys<V> keys () {
if (keys == null)
keys = new Keys(this);
keys = new Keys<V>(this);
else
keys.reset();
return keys;
Expand Down Expand Up @@ -618,9 +619,9 @@ public void remove () {
}

static public class Entries<V> extends MapIterator<V> implements Iterable<Entry<V>>, Iterator<Entry<V>> {
private Entry<V> entry = new Entry();
private Entry<V> entry = new Entry<V>();

public Entries (LongMap map) {
public Entries (LongMap<V> map) {
super(map);
}

Expand Down Expand Up @@ -675,15 +676,15 @@ public Iterator<V> iterator () {

/** Returns a new array containing the remaining values. */
public Array<V> toArray () {
Array array = new Array(true, map.size);
Array<V> array = new Array<V>(true, map.size);
while (hasNext)
array.add(next());
return array;
}
}

static public class Keys extends MapIterator {
public Keys (LongMap map) {
static public class Keys<V> extends MapIterator<V> {
public Keys (LongMap<V> map) {
super(map);
}

Expand Down
2 changes: 1 addition & 1 deletion src/com/badlogic/gdx/utils/Pool.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Pool (int initialCapacity) {

/** @param max The maximum number of free objects to store in this pool. */
public Pool (int initialCapacity, int max) {
freeObjects = new Array(false, initialCapacity);
freeObjects = new Array<T>(false, initialCapacity);
this.max = max;
}

Expand Down
15 changes: 8 additions & 7 deletions src/com/badlogic/gdx/utils/Sort.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
* Note that sorting primitive arrays with the Arrays.sort methods does not allocate memory (unless sorting large arrays of char,
* short, or byte).
* @author Nathan Sweet */
@SuppressWarnings("unchecked")
public class Sort {
static private Sort instance;

private TimSort timSort;
private TimSort<Object> timSort;
private ComparableTimSort comparableTimSort;

public <T> void sort (Array<T> a) {
Expand All @@ -43,18 +44,18 @@ public <T> void sort (T[] a, int fromIndex, int toIndex) {
}

public <T> void sort (Array<T> a, Comparator<T> c) {
if (timSort == null) timSort = new TimSort();
timSort.doSort(a.items, c, 0, a.size);
if (timSort == null) timSort = new TimSort<Object>();
timSort.doSort(a.items, (Comparator<Object>) c, 0, a.size);
}

public <T> void sort (T[] a, Comparator<T> c) {
if (timSort == null) timSort = new TimSort();
timSort.doSort(a, c, 0, a.length);
if (timSort == null) timSort = new TimSort<Object>();
timSort.doSort(a, (Comparator<Object>) c, 0, a.length);
}

public <T> void sort (T[] a, Comparator<T> c, int fromIndex, int toIndex) {
if (timSort == null) timSort = new TimSort();
timSort.doSort(a, c, fromIndex, toIndex);
if (timSort == null) timSort = new TimSort<Object>();
timSort.doSort(a, (Comparator<Object>) c, fromIndex, toIndex);
}

/** Returns a Sort instance for convenience. Multiple threads must not use this instance at the same time. */
Expand Down
17 changes: 9 additions & 8 deletions src/com/badlogic/gdx/utils/TimSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* While the API to this class consists solely of static methods, it is (privately) instantiable; a TimSort instance holds the
* state of an ongoing sort, assuming the input array is large enough to warrant the full-blown TimSort. Small arrays are sorted
* in place, using a binary insertion sort. */
@SuppressWarnings("unchecked")
class TimSort<T> {
/** This is the minimum sized sequence that will be merged. Shorter sequences will be lengthened by calling binarySort. If the
* entire array is less than this length, no merges will be performed.
Expand Down Expand Up @@ -93,34 +94,34 @@ class TimSort<T> {
runLen = new int[40];
}

public void doSort (T[] a, Comparator<T> c, int lo, int hi) {
public void doSort (T[] items, Comparator<T> c2, int lo, int hi) {
stackSize = 0;
rangeCheck(a.length, lo, hi);
rangeCheck(items.length, lo, hi);
int nRemaining = hi - lo;
if (nRemaining < 2) return; // Arrays of size 0 and 1 are always sorted

// If array is small, do a "mini-TimSort" with no merges
if (nRemaining < MIN_MERGE) {
int initRunLen = countRunAndMakeAscending(a, lo, hi, c);
binarySort(a, lo, hi, lo + initRunLen, c);
int initRunLen = countRunAndMakeAscending(items, lo, hi, c2);
binarySort(items, lo, hi, lo + initRunLen, c2);
return;
}

this.a = a;
this.c = c;
this.a = items;
this.c = c2;
tmpCount = 0;

/** March over the array once, left to right, finding natural runs, extending short natural runs to minRun elements, and
* merging runs to maintain stack invariant. */
int minRun = minRunLength(nRemaining);
do {
// Identify next run
int runLen = countRunAndMakeAscending(a, lo, hi, c);
int runLen = countRunAndMakeAscending(items, lo, hi, c2);

// If run is short, extend to min(minRun, nRemaining)
if (runLen < minRun) {
int force = nRemaining <= minRun ? nRemaining : minRun;
binarySort(a, lo, lo + force, lo + runLen, c);
binarySort(items, lo, lo + force, lo + runLen, c2);
runLen = force;
}

Expand Down