public void put(Topology<K> t, V v) {
for(Topology<K> ht : h.keySet()) {
if (t.disjoint(ht)) continue;
- if (t.equals(ht)) {
+ if (t.containsAll(ht) && ht.containsAll(t)) {
h.get(ht).add(v);
return;
}
return true;
}
- public boolean contains(K k) { return get(k).iterator().hasNext(); }
+ public boolean contains(K k) { return has(k); }
public boolean contains(K k, V v) {
for(Topology<K> t : h.keySet())
return false;
}
+ public boolean has(K k) {
+ for(Topology<K> t : h.keySet())
+ if (t.contains(k) && !h.get(t).isEmpty())
+ return true;
+ return false;
+ }
+
private HashMap<K,Iterable<V>> cache = new HashMap<K,Iterable<V>>();
public Iterable<V> getAll(Topology<K> k) { return h.get(k); }
+
+ public <B,C> void invoke(K k, Invokable<V,B,C> ivbc, B b, C c) {
+ for(Topology<K> t : h.keySet())
+ if (t.contains(k))
+ for(V v : h.get(t))
+ ivbc.invoke(v, b, c);
+ }
+
public Iterable<V> get(K k) {
Iterable<V> c = cache.get(k);
if (c != null) return c;