chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Resize SRFI-4 vectors


From: Jeronimo Pellegrini
Subject: [Chicken-users] Resize SRFI-4 vectors
Date: Wed, 28 Apr 2010 10:46:24 -0300
User-agent: Mutt/1.5.20 (2009-06-14)

Hello,

Is there a way to resize SRFI-4 vectors without copying the
elements all over a new vector?

I'd like something like

#;1> (define a (make-u32vector 3))
#;2> a 
#u32(3 0)
#;3> (u32vector-set! a 0 1)
#;4> (u32vector-set! a 0 1)
#;5> (u32vector-set! a 1 1)
#;6> a
#u32(1 1)
#;7> (u32vector-resize! a 5)  ;; <- here!
#;8> a
#u32(1 1 4 0 2)  ;; <- wanted behavior

The newly allocated part of the vector would not initialized,
but the old part would intact, and not necessarily copied over
(but it *may* be necessary to copy the whole vector if the new
vector doesn't fit where the old one was -- that's OK, of
course).

This is interesting if you may need to resize vectors too often.

I suppose there's no way to do this, since I found no reference to
such a function in the documentation and also I see that these vectors
are allocated by a "C_make_structure" function in runtime.c, but there
is no "C_resize_structure" or anything like that...

Thanks,
J.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]