quadtrees: Remove creative stack effects and {names}.

modern-harvey2
Doug Coleman 2017-07-23 15:13:56 -05:00
parent 40d9767084
commit bb756c8823
1 changed files with 6 additions and 6 deletions

View File

@ -59,7 +59,7 @@ DEFER: in-rect*
: ur-bounds ( rect -- rect' ) : ur-bounds ( rect -- rect' )
[ [ loc>> ] [ dim>> { 0.5 0.5 } v* ] bi v+ ] [ child-dim ] bi <rect> ; [ [ loc>> ] [ dim>> { 0.5 0.5 } v* ] bi v+ ] [ child-dim ] bi <rect> ;
: {quadrants} ( node -- quadrants ) : node>quadrants ( node -- quadrants )
{ [ ll>> ] [ lr>> ] [ ul>> ] [ ur>> ] } cleave 4array ; { [ ll>> ] [ lr>> ] [ ul>> ] [ ur>> ] } cleave 4array ;
: add-subnodes ( node -- node ) : add-subnodes ( node -- node )
@ -120,17 +120,17 @@ DEFER: in-rect*
: erase ( point tree -- ) : erase ( point tree -- )
dup leaf?>> [ leaf-erase ] [ node-erase ] if ; dup leaf?>> [ leaf-erase ] [ node-erase ] if ;
: (?leaf) ( quadrant -- {point,value}/f ) : (?leaf) ( quadrant -- pair/f )
dup point>> [ swap value>> 2array ] [ drop f ] if* ; dup point>> [ swap value>> 2array ] [ drop f ] if* ;
: ?leaf ( quadrants -- {point,value}/f ) : ?leaf ( quadrants -- pair/f )
[ (?leaf) ] map sift dup length { [ (?leaf) ] map sift dup length {
{ 1 [ first ] } { 1 [ first ] }
{ 0 [ drop { f f } ] } { 0 [ drop { f f } ] }
[ 2drop f ] [ 2drop f ]
} case ; } case ;
: collapseable? ( node -- {point,value}/f ) : collapseable? ( node -- pair/f )
{quadrants} { [ [ leaf?>> ] all? ] [ ?leaf ] } 1&& ; node>quadrants { [ [ leaf?>> ] all? ] [ ?leaf ] } 1&& ;
: remove-subnodes ( node -- leaf ) f >>ll f >>lr f >>ul f >>ur t >>leaf? ; : remove-subnodes ( node -- leaf ) f >>ll f >>lr f >>ul f >>ur t >>leaf? ;
@ -162,7 +162,7 @@ DEFER: in-rect*
: leaf= ( a b -- ? ) [ [ point>> ] [ value>> ] bi 2array ] same? ; : leaf= ( a b -- ? ) [ [ point>> ] [ value>> ] bi 2array ] same? ;
: node= ( a b -- ? ) [ {quadrants} ] same? ; : node= ( a b -- ? ) [ node>quadrants ] same? ;
: (tree=) ( a b -- ? ) dup leaf?>> [ leaf= ] [ node= ] if ; : (tree=) ( a b -- ? ) dup leaf?>> [ leaf= ] [ node= ] if ;