factor/library/collections/vectors.factor

16 lines
501 B
Factor
Raw Normal View History

! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
2005-05-05 22:30:58 -04:00
IN: vectors
2005-04-02 02:39:33 -05:00
USING: errors generic kernel kernel-internals lists math
math-internals sequences ;
M: vector set-length ( len vec -- ) grow-length ;
M: vector nth ( n vec -- obj ) bounds-check underlying array-nth ;
2004-12-24 02:52:02 -05:00
2005-05-05 22:30:58 -04:00
M: vector set-nth ( obj n vec -- )
growable-check 2dup ensure underlying set-array-nth ;
2004-12-24 02:52:02 -05:00
2005-04-06 21:41:49 -04:00
M: vector hashcode ( vec -- n )
dup length 0 number= [ drop 0 ] [ first hashcode ] ifte ;