keys_to_list

This commit is contained in:
Vitor Santos Costa 2017-07-05 03:36:42 +01:00
parent c0cf2b0b83
commit 1a78144190

View File

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