develooper Front page | perl.perl6.porters | Postings from April 2000

Re: Simplfied vector<> ?

Thread Previous | Thread Next
From:
Jean-Louis Leroy
Date:
April 30, 2000 00:28
Subject:
Re: Simplfied vector<> ?
Message ID:
m3u2gkvxp7.fsf@enterprise.newedgeconcept
> The standard C++ vector<> container is almost perfect for use in Perl
> arrays and the data stack.  But it has a major weakness...  It's _so_
> general that it doesn't use memcpy() [or moral equivalent] when it has
> to grow.  Instead, it uses copy constructors in a loop.  That could be
> a major performance issue with vector<Counted_p<T>>.

Have you considered deque<>? It doesn't copy the elements when
growing.

> Now, I could write a vector<>

Do you mean a vector_Counted_p<>? Better create a partial
specialization of vector<>:

        template<class T, class A>
        class vector<Counted_p<T>, A>
        {
                // ...
        };
-- 
Jean-Louis Leroy
http://users.skynet.be/jll

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About