2005-01-25 19:40:57 -05:00
|
|
|
! Copyright (C) 2004, 2005 Slava Pestov.
|
2005-01-29 14:18:28 -05:00
|
|
|
! 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 ;
|
2005-01-25 19:40:57 -05:00
|
|
|
|
2005-07-20 00:28:07 -04:00
|
|
|
M: vector set-length ( len vec -- ) grow-length ;
|
2005-04-26 00:35:55 -04:00
|
|
|
|
2005-07-20 00:28:07 -04:00
|
|
|
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 )
|
2005-05-28 20:52:23 -04:00
|
|
|
dup length 0 number= [ drop 0 ] [ first hashcode ] ifte ;
|