1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.accessors kernel math sequences
8 { length array-capacity read-only initial: 0 } ;
10 M: byte-array clone (clone) ; inline
11 M: byte-array clone-like
12 over byte-array? [ drop clone ] [ call-next-method ] if ; inline
13 M: byte-array length length>> ; inline
14 M: byte-array nth-unsafe swap integer>fixnum alien-unsigned-1 ; inline
15 M: byte-array set-nth-unsafe swap integer>fixnum set-alien-unsigned-1 ; inline
16 : >byte-array ( seq -- byte-array ) B{ } clone-like ; inline
17 M: byte-array new-sequence drop (byte-array) ; inline
20 over byte-array? [ sequence= ] [ 2drop f ] if ;
23 resize-byte-array ; inline
25 INSTANCE: byte-array sequence
27 : 1byte-array ( x -- byte-array ) B{ } 1sequence ; inline
29 : 2byte-array ( x y -- byte-array ) B{ } 2sequence ; inline
31 : 3byte-array ( x y z -- byte-array ) B{ } 3sequence ; inline
33 : 4byte-array ( w x y z -- byte-array ) B{ } 4sequence ; inline