mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
treap.erl backport
SVN Revision: 2400
This commit is contained in:
parent
504cc7b7dd
commit
c6f3fbb82c
@ -44,7 +44,7 @@ insert(Key, Priority, Value, Tree) ->
|
|||||||
|
|
||||||
insert1(nil, HashKey, Priority, Value) ->
|
insert1(nil, HashKey, Priority, Value) ->
|
||||||
{HashKey, Priority, Value, nil, nil};
|
{HashKey, Priority, Value, nil, nil};
|
||||||
insert1({HashKey1, Priority1, Value1, Left, Right},
|
insert1({HashKey1, Priority1, Value1, Left, Right} = Tree,
|
||||||
HashKey, Priority, Value) ->
|
HashKey, Priority, Value) ->
|
||||||
if
|
if
|
||||||
HashKey < HashKey1 ->
|
HashKey < HashKey1 ->
|
||||||
@ -55,8 +55,10 @@ insert1({HashKey1, Priority1, Value1, Left, Right},
|
|||||||
heapify({HashKey1, Priority1, Value1,
|
heapify({HashKey1, Priority1, Value1,
|
||||||
Left,
|
Left,
|
||||||
insert1(Right, HashKey, Priority, Value)});
|
insert1(Right, HashKey, Priority, Value)});
|
||||||
|
Priority == Priority1 ->
|
||||||
|
{HashKey, Priority, Value, Left, Right};
|
||||||
true ->
|
true ->
|
||||||
erlang:error(key_exists)
|
insert1(delete_root(Tree), HashKey, Priority, Value)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
heapify(nil) ->
|
heapify(nil) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user