keys_to_list

This commit is contained in:
Vitor Santos Costa 2017-07-05 03:36:42 +01:00
parent c0cf2b0b83
commit 1a78144190
1 changed files with 89 additions and 70 deletions

View File

@ -44,6 +44,8 @@
rb_key_fold/4,
list_to_rbtree/2,
ord_list_to_rbtree/2,
keys_to_rbtree/2,
ord_keys_to_rbtree/2,
is_rbtree/1,
rb_size/2,
rb_in/3
@ -1027,6 +1029,24 @@ keys(black(L,K,_,R),L0,Lf) :-
%
% T is the red-black tree corresponding to the mapping in list L.
keys_to_rbtree(List, T) :-
sort(List,Sorted),
ord_keys_to_rbtree(Sorted, T).
%% list_to_rbtree(+L, -T) is det.
%
% T is the red-black tree corresponding to the mapping in list L.
ord_keys_to_rbtree(List, T) :-
maplist(paux, List, Sorted),
ord_list_to_rbtree(Sorted, T).
paux(K, K-_).
%% list_to_rbtree(+L, -T) is det.
%
% T is the red-black tree corresponding to the mapping in list L.
list_to_rbtree(List, T) :-
sort(List,Sorted),
ord_list_to_rbtree(Sorted, T).
@ -1434,4 +1454,3 @@ with _NewVal_. Fails if it cannot find _Key_ in _T_.
*/
%%! @}