mirror of
https://github.com/corda/corda.git
synced 2025-06-19 23:53:52 +00:00
Added method addAll to interface Map
This commit is contained in:
@ -33,8 +33,8 @@ public class Collections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class SynchronizedCollection<T> implements Collection<T> {
|
static class SynchronizedCollection<T> implements Collection<T> {
|
||||||
private final Object lock;
|
protected final Object lock;
|
||||||
private final Collection<T> collection;
|
protected final Collection<T> collection;
|
||||||
|
|
||||||
public SynchronizedCollection(Object lock, Collection<T> collection) {
|
public SynchronizedCollection(Object lock, Collection<T> collection) {
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
@ -73,6 +73,11 @@ public class Collections {
|
|||||||
public SynchronizedSet(Object lock, Set<T> set) {
|
public SynchronizedSet(Object lock, Set<T> set) {
|
||||||
super(lock, set);
|
super(lock, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAll(Collection<T> c) {
|
||||||
|
synchronized (lock) { ((Set<T>)collection).addAll(c); }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SynchronizedIterator<T> implements Iterator<T> {
|
static class SynchronizedIterator<T> implements Iterator<T> {
|
||||||
|
@ -286,6 +286,10 @@ public class HashMap<K, V> implements Map<K, V> {
|
|||||||
return HashMap.this.size();
|
return HashMap.this.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAll(Collection<Entry<K, V>> c) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean contains(Entry<K, V> e) {
|
public boolean contains(Entry<K, V> e) {
|
||||||
return containsKey(e.getKey());
|
return containsKey(e.getKey());
|
||||||
}
|
}
|
||||||
@ -316,6 +320,10 @@ public class HashMap<K, V> implements Map<K, V> {
|
|||||||
return containsKey(key);
|
return containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAll(Collection<K> c) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean add(K key) {
|
public boolean add(K key) {
|
||||||
return putCell(key, null) != null;
|
return putCell(key, null) != null;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
package java.util;
|
package java.util;
|
||||||
|
|
||||||
public interface Set<T> extends Collection<T> { }
|
public interface Set<T> extends Collection<T> {
|
||||||
|
public void addAll(Collection<T> c);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user