aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <xramtsov@gmail.com>2009-07-29 03:40:56 +0000
committerEvgeniy Khramtsov <xramtsov@gmail.com>2009-07-29 03:40:56 +0000
commita528c62bba3ac2bca670e71083ce513e4aa8ef92 (patch)
treec2d7b80baced0d181f2bee2634c21388668e23fc
parentEJAB-940: Implements reliable ODBC transaction nesting. (diff)
update existing key instead of dropping an error
SVN Revision: 2398
-rw-r--r--src/treap.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/treap.erl b/src/treap.erl
index 360f543de..42438f228 100644
--- a/src/treap.erl
+++ b/src/treap.erl
@@ -44,7 +44,7 @@ insert(Key, Priority, Value, Tree) ->
insert1(nil, HashKey, Priority, Value) ->
{HashKey, Priority, Value, nil, nil};
-insert1({HashKey1, Priority1, Value1, Left, Right},
+insert1({HashKey1, Priority1, Value1, Left, Right} = Tree,
HashKey, Priority, Value) ->
if
HashKey < HashKey1 ->
@@ -55,8 +55,10 @@ insert1({HashKey1, Priority1, Value1, Left, Right},
heapify({HashKey1, Priority1, Value1,
Left,
insert1(Right, HashKey, Priority, Value)});
+ Priority == Priority1 ->
+ {HashKey, Priority, Value, Left, Right};
true ->
- erlang:error(key_exists)
+ insert1(delete_root(Tree), HashKey, Priority, Value)
end.
heapify(nil) ->