 
 GENERIC: equiv-set-size ( a disjoint-set -- n )
 
-M: disjoint-set equiv-set-size [ representative ] keep count ;
+M: disjoint-set equiv-set-size
+    [ representative ] keep counts>> at ;
 
 GENERIC: equiv? ( a b disjoint-set -- ? )
 


<PRIVATE

: count ( a disjoint-set -- n )
    counts>> at ; inline

: add-count ( p a disjoint-set -- )
    [ count [ + ] curry ] keep counts>> swap change-at ; inline

: parent ( a disjoint-set -- p )
    parents>> at ; inline

: set-parent ( p a disjoint-set -- )
    parents>> set-at ; inline

! Copyright (C) 2008 Eric Mertens.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs fry hashtables kernel locals math
sequences ;
FROM: assocs => change-at ;
IN: disjoint-sets

