extra fixes to list_to_rbtree
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2263 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
a3272bb0f9
commit
39e72437b0
@ -853,12 +853,9 @@ keys(black(L,K,_,R),L0,Lf) :-
|
|||||||
%
|
%
|
||||||
% 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(Nil,Tree)) :-
|
list_to_rbtree(List, T) :-
|
||||||
Nil = black([], [], [], []),
|
|
||||||
sort(List,Sorted),
|
sort(List,Sorted),
|
||||||
Ar =.. [seq|Sorted],
|
ord_list_to_rbtree(Sorted, T).
|
||||||
functor(Ar,_,L),
|
|
||||||
construct_rbtree(1, L, Ar, black, Nil, Tree).
|
|
||||||
|
|
||||||
%% ord_list_to_rbtree(+L, -T) is det.
|
%% ord_list_to_rbtree(+L, -T) is det.
|
||||||
%
|
%
|
||||||
@ -867,6 +864,8 @@ list_to_rbtree(List, t(Nil,Tree)) :-
|
|||||||
|
|
||||||
ord_list_to_rbtree([], t(Nil,Nil)) :- !,
|
ord_list_to_rbtree([], t(Nil,Nil)) :- !,
|
||||||
Nil = black([], [], [], []).
|
Nil = black([], [], [], []).
|
||||||
|
ord_list_to_rbtree([K-V], t(Nil,black(Nil,K,V,Nil))) :- !,
|
||||||
|
Nil = black([], [], [], []).
|
||||||
ord_list_to_rbtree(List, t(Nil,Tree)) :-
|
ord_list_to_rbtree(List, t(Nil,Tree)) :-
|
||||||
Nil = black([], [], [], []),
|
Nil = black([], [], [], []),
|
||||||
Ar =.. [seq|List],
|
Ar =.. [seq|List],
|
||||||
@ -924,7 +923,7 @@ is_rbtree(t(_,T)) :-
|
|||||||
is_rbtree(X,_) :-
|
is_rbtree(X,_) :-
|
||||||
var(X), !, fail.
|
var(X), !, fail.
|
||||||
is_rbtree(T,Goal) :-
|
is_rbtree(T,Goal) :-
|
||||||
catch(rbtree1(T), msg(S,Args), (format('when doing ~w~n got ~w',[Goal,T]), format(S,Args), trace, Goal)).
|
catch(rbtree1(T), msg(S,Args), format(S,Args)).
|
||||||
|
|
||||||
%
|
%
|
||||||
% This code checks if a tree is ordered and a rbtree
|
% This code checks if a tree is ordered and a rbtree
|
||||||
|
Reference in New Issue
Block a user