factor/core/collections/sbuf.factor

22 lines
685 B
Factor
Raw Permalink Normal View History

2006-10-31 00:52:02 -05:00
! Copyright (C) 2004, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2005-04-02 02:39:33 -05:00
IN: strings
USING: kernel math strings sequences-internals sequences ;
2005-04-02 02:39:33 -05:00
2006-10-31 00:52:02 -05:00
: <sbuf> ( n -- sbuf )
0 <string> string>sbuf 0 over set-fill ;
2005-12-30 03:57:38 -05:00
M: sbuf set-length grow-length ;
M: sbuf nth-unsafe underlying nth-unsafe ;
M: sbuf nth bounds-check nth-unsafe ;
M: sbuf set-nth-unsafe underlying set-nth-unsafe ;
M: sbuf set-nth growable-check 2dup ensure set-nth-unsafe ;
M: sbuf clone clone-resizable ;
2006-11-26 19:09:37 -05:00
M: sbuf new drop <sbuf> ;
2006-08-16 21:55:53 -04:00
: >sbuf ( seq -- sbuf ) [ sbuf? ] [ <sbuf> ] >sequence ; inline
2006-10-31 00:52:02 -05:00
M: sbuf like
drop dup sbuf? [
dup string? [ string>sbuf ] [ >sbuf ] if
] unless ;