public assoc ( object key, object val ) : IPersistentMap | ||
key | object | The key |
val | object | The value |
Результат | IPersistentMap |
public override IPersistentMap assoc(object key, object val)
{
Box found = new Box(null);
Node t = Add(_tree, key, val, found);
if (t == null)
{
Node foundNode = (Node)found.Val;
if (foundNode.Val == val)
return this;
return new PersistentTreeMap(_comp, Replace(_tree, key, val), _count, meta());
}
return new PersistentTreeMap(_comp, t.Blacken(), _count + 1, meta());
}
public static PersistentTreeMap create(IComparer comp, ISeq items) { IPersistentMap ret = new PersistentTreeMap(comp); for (; items != null; items = items.next().next()) { if (items.next() == null) { throw new ArgumentException(string.Format("No value supplied for key: {0}", items.first())); } ret = ret.assoc(items.first(), RT.second(items)); } return((PersistentTreeMap)ret); }