Merge branch 'master' of oss.readytalk.com:/var/local/git/avian

This commit is contained in:
Joel Dice 2009-04-23 13:35:21 -06:00
commit 34167cf63c
13 changed files with 34 additions and 30 deletions

View File

@ -33,7 +33,7 @@ public abstract class AbstractCollection<T> implements Collection<T> {
+ this.getClass().getName()); + this.getClass().getName());
} }
public boolean contains(T element) { public boolean contains(Object element) {
if (element != null) { if (element != null) {
for (Iterator<T> iter = iterator(); iter.hasNext();) { for (Iterator<T> iter = iterator(); iter.hasNext();) {
if (element.equals(iter.next())) { if (element.equals(iter.next())) {
@ -55,7 +55,7 @@ public abstract class AbstractCollection<T> implements Collection<T> {
return size() == 0; return size() == 0;
} }
public boolean remove(T element) { public boolean remove(Object element) {
throw new UnsupportedOperationException("remove(T) in " throw new UnsupportedOperationException("remove(T) in "
+ this.getClass().getName()); + this.getClass().getName());
} }

View File

@ -66,7 +66,7 @@ public class ArrayList<T> implements List<T> {
return size; return size;
} }
public boolean contains(T element) { public boolean contains(Object element) {
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
if (equal(element, array[i])) { if (equal(element, array[i])) {
return true; return true;
@ -145,7 +145,7 @@ public class ArrayList<T> implements List<T> {
return v; return v;
} }
public boolean remove(T element) { public boolean remove(Object element) {
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
if (equal(element, array[i])) { if (equal(element, array[i])) {
remove(i); remove(i);

View File

@ -64,7 +64,7 @@ public class Arrays {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public boolean contains(T element) { public boolean contains(Object element) {
for (int i = 0; i < array.length; ++i) { for (int i = 0; i < array.length; ++i) {
if (equal(element, array[i])) { if (equal(element, array[i])) {
return true; return true;
@ -93,7 +93,7 @@ public class Arrays {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public boolean remove(T element) { public boolean remove(Object element) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -21,7 +21,7 @@ public interface Collection<T> extends Iterable<T> {
public boolean addAll(Collection<? extends T> collection); public boolean addAll(Collection<? extends T> collection);
public boolean remove(T element); public boolean remove(Object element);
public <S> S[] toArray(S[] array); public <S> S[] toArray(S[] array);

View File

@ -97,7 +97,7 @@ public class Collections {
return size() == 0; return size() == 0;
} }
public boolean contains(T e) { public boolean contains(Object e) {
synchronized (lock) { return collection.contains(e); } synchronized (lock) { return collection.contains(e); }
} }
@ -109,8 +109,8 @@ public class Collections {
synchronized (lock) { return this.collection.addAll(collection); } synchronized (lock) { return this.collection.addAll(collection); }
} }
public boolean remove(T e) { public boolean remove(Object e) {
synchronized (lock) { return collection.remove(e); } synchronized (lock) { return collection.remove((T)e); }
} }
public <T> T[] toArray(T[] array) { public <T> T[] toArray(T[] array) {
@ -152,7 +152,7 @@ public class Collections {
public Set<java.util.Map.Entry<K, V>> entrySet() { public Set<java.util.Map.Entry<K, V>> entrySet() {
synchronized (lock) { return new SynchronizedSet<java.util.Map.Entry<K, V>>(lock, map.entrySet()); } synchronized (lock) { return new SynchronizedSet<java.util.Map.Entry<K, V>>(lock, map.entrySet()); }
} }
public V get(K key) { public V get(Object key) {
synchronized (lock) { return map.get(key); } synchronized (lock) { return map.get(key); }
} }
public boolean isEmpty() { public boolean isEmpty() {
@ -167,7 +167,7 @@ public class Collections {
public void putAll(Map<? extends K, ? extends V> elts) { public void putAll(Map<? extends K, ? extends V> elts) {
synchronized (lock) { map.putAll(elts); } synchronized (lock) { map.putAll(elts); }
} }
public V remove(K key) { public V remove(Object key) {
synchronized (lock) { return map.remove(key); } synchronized (lock) { return map.remove(key); }
} }
public int size() { public int size() {
@ -283,7 +283,7 @@ public class Collections {
throw new UnsupportedOperationException("not supported"); throw new UnsupportedOperationException("not supported");
} }
public boolean contains(T element) { public boolean contains(Object element) {
return inner.contains(element); return inner.contains(element);
} }
@ -295,7 +295,7 @@ public class Collections {
return inner.iterator(); return inner.iterator();
} }
public boolean remove(T element) { public boolean remove(Object element) {
throw new UnsupportedOperationException("not supported"); throw new UnsupportedOperationException("not supported");
} }

View File

@ -337,6 +337,10 @@ public class HashMap<K, V> implements Map<K, V> {
return change; return change;
} }
public boolean remove(Object o) {
return (o instanceof Entry<?,?>) ? remove((Entry<?,?>)o) : false;
}
public boolean remove(Entry<K, V> e) { public boolean remove(Entry<K, V> e) {
return removeCell(e.getKey()) != null; return removeCell(e.getKey()) != null;
} }
@ -416,7 +420,7 @@ public class HashMap<K, V> implements Map<K, V> {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public boolean remove(V value) { public boolean remove(Object value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -36,7 +36,7 @@ public class HashSet<T> implements Set<T> {
return map.isEmpty(); return map.isEmpty();
} }
public boolean contains(T element) { public boolean contains(Object element) {
return map.containsKey(element); return map.containsKey(element);
} }
@ -50,7 +50,7 @@ public class HashSet<T> implements Set<T> {
return change; return change;
} }
public boolean remove(T element) { public boolean remove(Object element) {
return map.remove(element) != Value; return map.remove(element) != Value;
} }

View File

@ -48,7 +48,7 @@ public class Hashtable<K, V> implements Map<K, V> {
return map.containsValue(value); return map.containsValue(value);
} }
public synchronized V get(K key) { public synchronized V get(Object key) {
return map.get(key); return map.get(key);
} }
@ -60,7 +60,7 @@ public class Hashtable<K, V> implements Map<K, V> {
map.putAll(elts); map.putAll(elts);
} }
public synchronized V remove(K key) { public synchronized V remove(Object key) {
return map.remove(key); return map.remove(key);
} }

View File

@ -37,7 +37,7 @@ public class IdentityHashMap<K, V> implements Map<K, V> {
return map.containsValue(value); return map.containsValue(value);
} }
public V get(K key) { public V get(Object key) {
return map.get(key); return map.get(key);
} }
@ -49,7 +49,7 @@ public class IdentityHashMap<K, V> implements Map<K, V> {
map.putAll(elts); map.putAll(elts);
} }
public V remove(K key) { public V remove(Object key) {
return map.remove(key); return map.remove(key);
} }

View File

@ -60,7 +60,7 @@ public class LinkedList<T> implements List<T> {
} }
} }
private Cell<T> find(T element) { private Cell<T> find(Object element) {
for (Cell<T> c = front; c != null; c = c.next) { for (Cell<T> c = front; c != null; c = c.next) {
if (equal(c.value, element)) { if (equal(c.value, element)) {
return c; return c;
@ -93,7 +93,7 @@ public class LinkedList<T> implements List<T> {
return size; return size;
} }
public boolean contains(T element) { public boolean contains(Object element) {
return find(element) != null; return find(element) != null;
} }
@ -186,7 +186,7 @@ public class LinkedList<T> implements List<T> {
} }
} }
public boolean remove(T element) { public boolean remove(Object element) {
Cell<T> c = find(element); Cell<T> c = find(element);
if (c == null) { if (c == null) {
return false; return false;

View File

@ -60,7 +60,7 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
} }
} }
public boolean remove(T value) { public boolean remove(Object value) {
PersistentSet.Path<Cell<T>> p = set.find(new Cell(value, null)); PersistentSet.Path<Cell<T>> p = set.find(new Cell(value, null));
if (p.fresh()) { if (p.fresh()) {
return false; return false;
@ -85,7 +85,7 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
return size == 0; return size == 0;
} }
public boolean contains(T value) { public boolean contains(Object value) {
return !set.find(new Cell(value, null)).fresh(); return !set.find(new Cell(value, null)).fresh();
} }

View File

@ -29,7 +29,7 @@ public class Vector<T> implements List<T> {
return list.size(); return list.size();
} }
public synchronized boolean contains(T element) { public synchronized boolean contains(Object element) {
return list.contains(element); return list.contains(element);
} }
@ -85,7 +85,7 @@ public class Vector<T> implements List<T> {
remove(index); remove(index);
} }
public synchronized boolean remove(T element) { public synchronized boolean remove(Object element) {
return list.remove(element); return list.remove(element);
} }

View File

@ -54,7 +54,7 @@ public class WeakHashMap<K, V> implements Map<K, V> {
return map.containsValue(value); return map.containsValue(value);
} }
public V get(K key) { public V get(Object key) {
poll(); poll();
return map.get(key); return map.get(key);
} }
@ -68,7 +68,7 @@ public class WeakHashMap<K, V> implements Map<K, V> {
map.putAll(elts); map.putAll(elts);
} }
public V remove(K key) { public V remove(Object key) {
poll(); poll();
return map.remove(key); return map.remove(key);
} }