public void add(Topology<K> t, V v) { put(t, v); }
public void addAll(Topology<K> k, Iterable<V> vi) { putAll(k, vi); }
- public void putAll(Topology<K> k, Iterable<V> vi) { for(V v : vi) put(k, v); }
+ public void putAll(Topology<K> k, Iterable<V> vi) { if (vi!=null) for(V v : vi) put(k, v); }
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;
}
TopologicalBag<K,V> ret = new TopologicalBag<K,V>();
for(Topology<K> ht : h.keySet()) {
if (ht.disjoint(t)) continue;
- ret.putAll(ht.intersect(t), h.get(ht));
+ Iterable<V> it = h.get(ht);
+ Topology<K> tk = ht.intersect(t);
+ ret.putAll(tk, it);
}
return ret;
}
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 Iterable<V> get(K k) {