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

This commit is contained in:
Joel Dice 2009-04-27 14:19:53 +00:00
commit abc9da9b31
15 changed files with 76 additions and 56 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

@ -15,13 +15,13 @@ public interface Collection<T> extends Iterable<T> {
public boolean isEmpty(); public boolean isEmpty();
public boolean contains(T element); public boolean contains(Object element);
public boolean add(T element); public boolean add(T element);
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) {
@ -143,16 +143,16 @@ public class Collections {
public void clear() { public void clear() {
synchronized (lock) { map.clear(); } synchronized (lock) { map.clear(); }
} }
public boolean containsKey(K key) { public boolean containsKey(Object key) {
synchronized (lock) { return map.containsKey(key); } synchronized (lock) { return map.containsKey(key); }
} }
public boolean containsValue(V value) { public boolean containsValue(Object value) {
synchronized (lock) { return map.containsValue(value); } synchronized (lock) { return map.containsValue(value); }
} }
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

@ -107,7 +107,7 @@ public class HashMap<K, V> implements Map<K, V> {
array = newArray; array = newArray;
} }
private Cell<K, V> find(K key) { private Cell<K, V> find(Object key) {
if (array != null) { if (array != null) {
int index = helper.hash(key) & (array.length - 1); int index = helper.hash(key) & (array.length - 1);
for (Cell<K, V> c = array[index]; c != null; c = c.next()) { for (Cell<K, V> c = array[index]; c != null; c = c.next()) {
@ -158,20 +158,29 @@ public class HashMap<K, V> implements Map<K, V> {
return c; return c;
} }
public boolean containsKey(K key) { public boolean containsKey(Object key) {
return find(key) != null; return find(key) != null;
} }
public boolean containsValue(V value) { public boolean containsValue(Object value) {
return values().contains(value); if (array != null) {
int index = array.length - 1;
for (Cell<K, V> c = array[index]; c != null; c = c.next()) {
if (helper.equal(value, c.getValue())) {
return true;
}
}
}
return false;
} }
public V get(K key) { public V get(Object key) {
Cell<K, V> c = find(key); Cell<K, V> c = find(key);
return (c == null ? null : c.getValue()); return (c == null ? null : c.getValue());
} }
public Cell<K, V> removeCell(K key) { public Cell<K, V> removeCell(Object key) {
Cell<K, V> old = null; Cell<K, V> old = null;
if (array != null) { if (array != null) {
int index = helper.hash(key) & (array.length - 1); int index = helper.hash(key) & (array.length - 1);
@ -213,8 +222,8 @@ public class HashMap<K, V> implements Map<K, V> {
} }
} }
public V remove(K key) { public V remove(Object key) {
Cell<K, V> c = removeCell(key); Cell<K, V> c = removeCell((K)key);
return (c == null ? null : c.getValue()); return (c == null ? null : c.getValue());
} }
@ -314,8 +323,8 @@ public class HashMap<K, V> implements Map<K, V> {
return HashMap.this.isEmpty(); return HashMap.this.isEmpty();
} }
public boolean contains(Entry<K, V> e) { public boolean contains(Object o) {
return containsKey(e.getKey()); return (o instanceof Entry<?,?>) ? containsKey(((Entry<?,?>)o).getKey()) : false;
} }
public boolean add(Entry<K, V> e) { public boolean add(Entry<K, V> e) {
@ -328,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;
} }
@ -354,7 +367,7 @@ public class HashMap<K, V> implements Map<K, V> {
return HashMap.this.isEmpty(); return HashMap.this.isEmpty();
} }
public boolean contains(K key) { public boolean contains(Object key) {
return containsKey(key); return containsKey(key);
} }
@ -368,7 +381,7 @@ public class HashMap<K, V> implements Map<K, V> {
return change; return change;
} }
public boolean remove(K key) { public boolean remove(Object key) {
return removeCell(key) != null; return removeCell(key) != null;
} }
@ -395,7 +408,7 @@ public class HashMap<K, V> implements Map<K, V> {
return HashMap.this.isEmpty(); return HashMap.this.isEmpty();
} }
public boolean contains(V value) { public boolean contains(Object value) {
return containsValue(value); return containsValue(value);
} }
@ -407,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

@ -40,15 +40,15 @@ public class Hashtable<K, V> implements Map<K, V> {
return map.size(); return map.size();
} }
public synchronized boolean containsKey(K key) { public synchronized boolean containsKey(Object key) {
return map.containsKey(key); return map.containsKey(key);
} }
public synchronized boolean containsValue(V value) { public synchronized boolean containsValue(Object value) {
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

@ -29,15 +29,15 @@ public class IdentityHashMap<K, V> implements Map<K, V> {
return map.size(); return map.size();
} }
public boolean containsKey(K key) { public boolean containsKey(Object key) {
return map.containsKey(key); return map.containsKey(key);
} }
public boolean containsValue(V value) { public boolean containsValue(Object value) {
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

@ -15,17 +15,17 @@ public interface Map<K, V> {
public int size(); public int size();
public boolean containsKey(K key); public boolean containsKey(Object obj);
public boolean containsValue(V value); public boolean containsValue(Object obj);
public V get(K key); public V get(Object key);
public V put(K key, V value); public V put(K key, V value);
public void putAll(Map<? extends K,? extends V> elts); public void putAll(Map<? extends K,? extends V> elts);
public V remove(K key); public V remove(Object key);
public void clear(); public void clear();

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

@ -44,17 +44,17 @@ public class WeakHashMap<K, V> implements Map<K, V> {
return map.size(); return map.size();
} }
public boolean containsKey(K key) { public boolean containsKey(Object key) {
poll(); poll();
return map.containsKey(key); return map.containsKey(key);
} }
public boolean containsValue(V value) { public boolean containsValue(Object value) {
poll(); poll();
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);
} }

View File

@ -334,6 +334,13 @@ test: build
$(executable) $(mode) "$(flags)" \ $(executable) $(mode) "$(flags)" \
$(call class-names,$(test-build),$(test-classes)) $(call class-names,$(test-build),$(test-classes))
.PHONY: tarball
tarball:
@echo "creating build/avian-$(version).tar.bz2"
@mkdir -p build
(cd .. && tar --exclude=build --exclude='.*' --exclude='*~' -cjf \
avian/build/avian-$(version).tar.bz2 avian)
.PHONY: javadoc .PHONY: javadoc
javadoc: javadoc:
javadoc -sourcepath classpath -d build/javadoc -subpackages java \ javadoc -sourcepath classpath -d build/javadoc -subpackages java \