factor/core/byte-arrays/byte-arrays.factor

22 lines
700 B
Factor
Raw Normal View History

2008-01-05 17:27:15 -05:00
! Copyright (C) 2007, 2008 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2008-01-31 21:11:46 -05:00
USING: kernel kernel.private alien.accessors sequences
sequences.private math ;
2007-09-20 18:09:08 -04:00
IN: byte-arrays
M: byte-array clone (clone) ;
M: byte-array length array-capacity ;
M: byte-array nth-unsafe swap >fixnum alien-unsigned-1 ;
M: byte-array set-nth-unsafe swap >fixnum set-alien-unsigned-1 ;
: >byte-array ( seq -- byte-array ) B{ } clone-like ; inline
M: byte-array like drop dup byte-array? [ >byte-array ] unless ;
M: byte-array new drop <byte-array> ;
M: byte-array equal?
over byte-array? [ sequence= ] [ 2drop f ] if ;
2008-01-28 19:15:21 -05:00
M: byte-array resize
resize-byte-array ;
2007-09-20 18:09:08 -04:00
INSTANCE: byte-array sequence