mirror of
https://github.com/corda/corda.git
synced 2025-06-13 12:48:18 +00:00
Added more to the avian classpath for the collection interface as well as the list interface
Added to collection: public boolean containsAll(Collection<?> c); public boolean removeAll(Collection<?> c); Added to list: public boolean addAll(int startIndex, Collection<? extends T> c); Also where possible for inner classes I made them extend the abstract version instead of just implement the interface. This helps reduce code duplication where possible. These changes were necessary to support protobuf 2.5.0
This commit is contained in:
@ -303,7 +303,7 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
private class EntrySet implements Set<Entry<K, V>> {
|
||||
private class EntrySet extends AbstractSet<Entry<K, V>> {
|
||||
public int size() {
|
||||
return HashMap.this.size();
|
||||
}
|
||||
@ -321,12 +321,6 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
return putCell(e.getKey(), e.getValue()) != null;
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends Entry<K, V>> collection) {
|
||||
boolean change = false;
|
||||
for (Entry<K, V> e: collection) if (add(e)) change = true;
|
||||
return change;
|
||||
}
|
||||
|
||||
public boolean remove(Object o) {
|
||||
return (o instanceof Entry<?,?>) && remove((Entry<?,?>)o);
|
||||
}
|
||||
@ -352,7 +346,7 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
private class KeySet implements Set<K> {
|
||||
private class KeySet extends AbstractSet<K> {
|
||||
public int size() {
|
||||
return HashMap.this.size();
|
||||
}
|
||||
@ -369,12 +363,6 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
return putCell(key, null) != null;
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends K> collection) {
|
||||
boolean change = false;
|
||||
for (K k: collection) if (add(k)) change = true;
|
||||
return change;
|
||||
}
|
||||
|
||||
public boolean remove(Object key) {
|
||||
return removeCell(key) != null;
|
||||
}
|
||||
@ -409,6 +397,21 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
return containsValue(value);
|
||||
}
|
||||
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
if (c == null) {
|
||||
throw new NullPointerException("collection is null");
|
||||
}
|
||||
|
||||
Iterator<?> it = c.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (! contains(it.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@ -421,6 +424,10 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Object[] toArray() {
|
||||
return toArray(new Object[size()]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user