Re: [Scheme-reports] vector-insert Per Bothner (20 Aug 2014 21:41 UTC)
Re: [Scheme-reports] vector-insert Taylan Ulrich Bayirli/Kammer (21 Aug 2014 09:08 UTC)
Re: [Scheme-reports] vector-insert Per Bothner (21 Aug 2014 16:13 UTC)
Re: [Scheme-reports] vector-insert Kevin Wortman (21 Aug 2014 17:00 UTC)
Re: [Scheme-reports] vector-insert Sascha Ziemann (22 Aug 2014 08:00 UTC)
Re: [Scheme-reports] vector-insert Kevin Wortman (23 Aug 2014 00:57 UTC)
Re: [Scheme-reports] vector-insert Vassil Nikolov (23 Aug 2014 22:36 UTC)

Re: [Scheme-reports] vector-insert Per Bothner 21 Aug 2014 16:08 UTC


On 08/21/2014 02:03 AM, Taylan Ulrich Bayirli/Kammer wrote:
> Per Bothner <per@bothner.com> writes:

>> Simple re-sizable vectors require an indirection that might otherwise
>> not be needed.  This overhead is much less than using linked lists.
>
> For accessing elements, yes.

Constructing a vector by appending to the end is also likely to be more efficient
than constructing a list: Less memory allocation/gc; better memory locality; about
the same memory needs.

>> Many programs needs to "build" a sequence, typically appending at the
>> end each element as it is produced.  Using an array that gets
>> reallocated (doubled) when full is usually the most efficient
>> representation.  Having a standard re-sizable (growable) vector type
>> would simplify the programming.
>
> I think the typical way of doing this is to cons up a reverse list,
> reverse! it, and use list->vector.  If the sequence is built at once
> then this should be fine.

Using a growable vector will be more efficient, and less programming.

--
	--Per Bothner
per@bothner.com   http://per.bothner.com/

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports