From fd61f719565f11967d4543e8a9cad186ba3ed511 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 13 Jul 2012 16:56:28 -0700 Subject: [PATCH] dlists: fix equality when custom dlist-link nodes are used. --- basis/dlists/dlists-tests.factor | 12 ++++++------ basis/dlists/dlists.factor | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/basis/dlists/dlists-tests.factor b/basis/dlists/dlists-tests.factor index d6b9fe9020..4f9a30085a 100644 --- a/basis/dlists/dlists-tests.factor +++ b/basis/dlists/dlists-tests.factor @@ -118,34 +118,34 @@ TUPLE: my-node < dlist-link { obj fixnum } ; [ prev>> ] [ next>> ] bi 2array { f f } assert= ; [ V{ } ] [ 1 over push-node-back [ [ back>> ] [ ] bi delete-node ] [ ] bi dlist>sequence ] unit-test -[ V{ 1 2 } ] [| | +[ V{ 1 2 } t ] [| | :> dl 1 :> n1 n1 dl push-node-back 2 :> n2 n2 dl push-node-back 3 :> n3 n3 dl push-node-back n3 dl delete-node n3 assert-links - dl dlist>sequence + dl dlist>sequence dup >dlist dl = ] unit-test -[ V{ 1 3 } ] [| | +[ V{ 1 3 } t ] [| | :> dl 1 :> n1 n1 dl push-node-back 2 :> n2 n2 dl push-node-back 3 :> n3 n3 dl push-node-back n2 dl delete-node n2 assert-links - dl dlist>sequence + dl dlist>sequence dup >dlist dl = ] unit-test -[ V{ 2 3 } ] [| | +[ V{ 2 3 } t ] [| | :> dl 1 :> n1 n1 dl push-node-back 2 :> n2 n2 dl push-node-back 3 :> n3 n3 dl push-node-back n1 dl delete-node n1 assert-links - dl dlist>sequence + dl dlist>sequence dup >dlist dl = ] unit-test diff --git a/basis/dlists/dlists.factor b/basis/dlists/dlists.factor index c186d8633e..cb512ad95c 100644 --- a/basis/dlists/dlists.factor +++ b/basis/dlists/dlists.factor @@ -12,6 +12,8 @@ TUPLE: dlist-node < dlist-link obj ; M: dlist-link obj>> ; +M: dlist-link node-value obj>> ; + : new-dlist-link ( obj prev next class -- node ) new swap >>next @@ -33,14 +35,12 @@ TUPLE: dlist M: dlist deque-empty? front>> not ; inline -M: dlist-node node-value obj>> ; - > ] bi@ = ] + [ [ dlist-link? ] both? ] + [ [ obj>> ] bi@ = ] } 2&& ; inline PRIVATE> @@ -49,7 +49,7 @@ M: dlist equal? over dlist? [ [ front>> ] bi@ [ 2dup dlist-nodes= ] - [ [ next>> ] bi@ ] while + [ [ next>> ] bi@ ] while or not ] [ 2drop f