]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/specialized-vectors/specialized-vectors.factor
specialized-vectors: add push-new operation that allocates and returns a new struct...
[factor.git] / basis / specialized-vectors / specialized-vectors.factor
index 3352c226d8b67c0a471e279823fcd5f8bfb81885..fd36121df1dd8df9d5d3d8968128de6ec05f0f34 100644 (file)
@@ -5,6 +5,7 @@ compiler.units functors growable kernel lexer math namespaces
 parser prettyprint.custom sequences specialized-arrays
 specialized-arrays.private strings vocabs vocabs.parser
 vocabs.generated fry make ;
+FROM: sequences.private => nth-unsafe ;
 QUALIFIED: vectors.functor
 IN: specialized-vectors
 
@@ -50,6 +51,9 @@ INSTANCE: V growable
 
 PRIVATE>
 
+: push-new ( vector -- new )
+    [ length ] keep ensure nth-unsafe ; inline
+
 : define-vector-vocab ( type -- vocab )
     underlying-type
     [ specialized-vector-vocab ] [ '[ _ define-vector ] ] bi