diff options
author | Rich Hickey <richhickey@gmail.com> | 2006-07-04 18:02:35 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2006-07-04 18:02:35 +0000 |
commit | 45928ffe7f2b9e59633fb7931f2a3c75c9d6589f (patch) | |
tree | cdade057178a2795ee134ea946cefff882c7c035 /src/cli/runtime/PersistentTree.cs | |
parent | 86a8196bbba908bf6cf3f5d9ab3d3ebb7f94a646 (diff) |
added val to add(), throws exception if key present
Diffstat (limited to 'src/cli/runtime/PersistentTree.cs')
-rw-r--r-- | src/cli/runtime/PersistentTree.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cli/runtime/PersistentTree.cs b/src/cli/runtime/PersistentTree.cs index b9335bdf..36f0346f 100644 --- a/src/cli/runtime/PersistentTree.cs +++ b/src/cli/runtime/PersistentTree.cs @@ -52,9 +52,14 @@ public bool contains(Object key){ return find(key) != null; }
- public IPersistentMap add(Object key)
+public IPersistentMap add(Object key,Object val){ + Box found = new Box(null); + Node t = add(tree, key, val, found); + if(t == null) //null == already contains key { - return put(key, null); + throw new Exception("Key already present");
+ } + return new PersistentTree(comp, t.blacken(), _count + 1); } public IPersistentMap put(Object key, Object val){ @@ -778,7 +783,7 @@ public void Reset() #endregion
} - /*
+ //*
[STAThread] static public void Main(String[] args){ if(args.Length != 1)
|