On 24/06/2009, at 12:23 PM, Erick Tryzelaar wrote:

> On Tue, Jun 23, 2009 at 7:16 PM, john
> skaller<skal...@users.sourceforge.net> wrote:
>> Some fun with varray tests, tried this:
>> ////
>> var b = varray[int] 20ul;
>> println$ len b;
>>
>> iter println of (int) b;
>> b+= 22;
>> b+= 33;
>> iter println of (int) b;
>>
>> c:= map (curry sub of (int * int) 100) b;
>> println c;
>> ///
>>
>> and it worked!
>>
>> varray(78, 67)
>
> Neat! I can't remember, do varray's automatically grow?

using += grows the used size, up to the allocated maximum.
After that I think C++ implementation throws an exception.

To make one that grows like C++ vector, use something like:

typedef rvarray = &varray;

or a more OO version of this:

typedef rvarray = & &varray;

and then reallocate the varray when it gets full.

Ideally, on platforms like Linux, we'd use mmap() instead of malloc,
and then extending a rvarray would not require copying anything
(just change the address of the existing pages). However the  
implementation
is a bit hairy and platform dependent.

--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to