public static Hashtable/*<Key,Value[]>*/ Compact(IRelation/*<Key,Value>*/ irel, Type value_type) { Hashtable hash = new Hashtable(); foreach(object key in irel.GetKeys()) { ISet vals = irel.GetValues(key); if(vals.Count == 0) continue; System.Array array_vals = System.Array.CreateInstance(value_type, vals.Count); vals.CopyTo(array_vals, 0); if (typeof(Node).IsAssignableFrom(value_type)) { Array.Sort(array_vals, DataStructUtil.NodeComparer); } hash.Add(key, array_vals); } return hash; }
public virtual bool AddRelation(IRelation relation) { if(relation == null) return false; bool changed = false; foreach(object key in relation.GetKeys()) if(this.AddAll(key, relation.GetValues(key))) changed = true; return changed; }