byte-vector
Factor documentation > Factor handbook > The language > Collections > Byte vectors
Next:byte-vector? ( object -- ? )


Vocabulary
byte-vectors

Word description
The class of resizable byte vectors. See Byte vectors for information.

Definition
USING: byte-arrays sequences.private ;

IN: byte-vectors

TUPLE: byte-vector
{ underlying byte-array initial: B{ } }
{ length array-capacity initial: 0 } ;


Methods
USING: byte-vectors prettyprint.custom ;

M: byte-vector >pprint-sequence ;


USING: alien byte-vectors sequences ;

M: byte-vector byte-length length ;


USING: byte-vectors growable kernel ;

M: byte-vector contract 2drop ; inline


USING: alien byte-vectors kernel ;

M: byte-vector element-size drop 1 ; inline


USING: byte-vectors kernel sequences ;

M: byte-vector equal?
over byte-vector? [ sequence= ] [ 2drop f ] if ;


USING: byte-vectors tools.hexdump tools.hexdump.private ;

M: byte-vector hexdump. hexdump-bytes ;


USING: byte-arrays byte-vectors kernel sequences ;

M: byte-vector like
drop dup byte-vector? [
dup byte-array?
[ dup length byte-vector boa ] [ >byte-vector ] if
] unless ; inline


USING: byte-vectors kernel sequences ;

M: byte-vector new-resizable drop <byte-vector> ; inline


USING: byte-arrays byte-vectors kernel math sequences ;

M: byte-vector new-sequence
drop [ (byte-array) ] [ >fixnum ] bi byte-vector boa ;
inline


USING: byte-vectors prettyprint.custom ;

M: byte-vector pprint* pprint-object ;


USING: byte-vectors kernel prettyprint.custom ;

M: byte-vector pprint-delims drop \ BV{ \ } ;


USING: byte-vectors kernel prettyprint.custom ;

M: byte-vector pprint-narrow? drop f ;


USING: byte-vectors io kernel ;

M: byte-vector stream-element-type drop +byte+ ;


USING: alien byte-vectors io kernel libc math sequences ;

M: byte-vector stream-write
[ dup byte-length tail-slice ]
[ [ [ byte-length ] bi@ + ] keep lengthen ]
[ drop byte-length ] 2tri [ >c-ptr swap >c-ptr ] dip memcpy
;