]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/circular/circular.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / basis / circular / circular.factor
old mode 100755 (executable)
new mode 100644 (file)
index 5d23781..b3be465
@@ -11,9 +11,11 @@ TUPLE: circular seq start ;
 : <circular> ( seq -- circular )
     0 circular boa ;
 
+<PRIVATE
 : circular-wrap ( n circular -- n circular )
     [ start>> + ] keep
     [ seq>> length rem ] keep ; inline
+PRIVATE>
 
 M: circular length seq>> length ;
 
@@ -25,8 +27,11 @@ M: circular virtual-seq seq>> ;
     #! change start to (start + n) mod length
     circular-wrap (>>start) ;
 
+: rotate-circular ( circular -- )
+    [ 1 ] dip change-circular-start ;
+
 : push-circular ( elt circular -- )
-    [ set-first ] [ 1 swap change-circular-start ] bi ;
+    [ set-first ] [ rotate-circular ] bi ;
 
 : <circular-string> ( n -- circular )
     0 <string> <circular> ;
@@ -37,15 +42,16 @@ TUPLE: growing-circular < circular length ;
 
 M: growing-circular length length>> ;
 
+<PRIVATE
+
 : full? ( circular -- ? )
     [ length ] [ seq>> length ] bi = ;
 
-: set-peek ( elt seq -- )
-    [ length 1- ] keep set-nth ;
+PRIVATE>
 
 : push-growing-circular ( elt circular -- )
     dup full? [ push-circular ]
-    [ [ 1+ ] change-length set-peek ] if ;
+    [ [ 1 + ] change-length set-last ] if ;
 
 : <growing-circular> ( capacity -- growing-circular )
     { } new-sequence 0 0 growing-circular boa ;