Merge github.com:ReadyTalk/avian

This commit is contained in:
Joel Dice 2012-07-24 16:17:09 -06:00
commit 2d6bfa5383
3 changed files with 53 additions and 0 deletions

View File

@ -15,6 +15,11 @@ public abstract class AbstractList<T> extends AbstractCollection<T>
{
protected int modCount;
public boolean add(T o) {
add(size(), o);
return true;
}
public Iterator<T> iterator() {
return listIterator();
}

View File

@ -42,6 +42,37 @@ public class Arrays {
}
}
public static int hashCode(Object[] array) {
if(array == null) {
return 9023;
}
int hc = 823347;
for(Object o : array) {
hc += o != null ? o.hashCode() : 54267;
hc *= 3;
}
return hc;
}
public static boolean equals(Object[] a, Object[] b) {
if(a == b) {
return true;
}
if(a == null || b == null) {
return false;
}
if(a.length != b.length) {
return false;
}
for(int i = 0; i < a.length; i++) {
if(!equal(a[i], b[i])) {
return false;
}
}
return true;
}
public static <T> List<T> asList(final T ... array) {
return new List<T>() {
public String toString() {

View File

@ -77,5 +77,22 @@ public class Arrays {
array[0] = Integer.valueOf(42);
expect(array[0].intValue() == 42);
}
{ Object[] a = new Object[3];
Object[] b = new Object[3];
expect(java.util.Arrays.equals(a, b));
a[0] = new Object();
expect(! java.util.Arrays.equals(a, b));
expect(! java.util.Arrays.equals(b, new Object[4]));
expect(! java.util.Arrays.equals(a, null));
expect(! java.util.Arrays.equals(null, b));
expect(java.util.Arrays.equals(null, null));
b[0] = a[0];
expect(java.util.Arrays.equals(a, b));
java.util.Arrays.hashCode(a);
java.util.Arrays.hashCode(null);
}
}
}