]> gitweb.factorcode.org Git - factor.git/commitdiff
grouping: circular-slice shouldn't be a subclass of slice since that thwarts method...
authorJoe Groff <arcata@gmail.com>
Fri, 26 Feb 2010 21:20:47 +0000 (13:20 -0800)
committerJoe Groff <arcata@gmail.com>
Fri, 26 Feb 2010 21:20:47 +0000 (13:20 -0800)
basis/grouping/grouping.factor

index 0dced6ad9d30b068a3252c4bec7d219b8ed74d34..304fd50fcc0c0510ef662c3b7d018ac731d4ddfa 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math math.order strings arrays vectors sequences
-sequences.private accessors fry combinators.short-circuit ;
+sequences.private accessors fry combinators.short-circuit
+combinators ;
 IN: grouping
 
 <PRIVATE
@@ -114,7 +115,15 @@ INSTANCE: sliced-clumps abstract-clumps
 
 : all-eq? ( seq -- ? ) [ eq? ] monotonic? ;
 
-TUPLE: circular-slice < slice ;
+TUPLE: circular-slice
+    { from read-only }
+    { to   read-only }
+    { seq  read-only } ;
+INSTANCE: circular-slice virtual-sequence
+M: circular-slice equal? over slice? [ sequence= ] [ 2drop f ] if ;
+M: circular-slice hashcode* [ sequence-hashcode ] recursive-hashcode ;
+M: circular-slice length [ to>> ] [ from>> ] bi - ; inline
+M: circular-slice virtual-exemplar seq>> ; inline
 M: circular-slice virtual@
     [ from>> + ] [ seq>> ] bi [ length slice-mod ] keep ; inline