Re: CArray and CList

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Steve Russell (srussell_at_removethisinnernet.net)
Date: 06/28/04


Date: Mon, 28 Jun 2004 06:21:02 -0400

Once again, thank you for the valuable education, Joe!
-----------------------
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:476ud099bkkmj8nrs8m6kiiphsjon1qp7d@4ax.com...
> Also, if you don't insert or delete very often, a CArray will allow this,
but you get a
> performance hit because it has to allocate a new array, copy the data up
to the
> insertion/deletion point, then copy the data after. This can be lengthy.
But if you are
> accessing the data frequently by index, it will give you faster access. So
it is all a
> tradeoff. If you are inserting or deleting a lot, but only walking the
sequence from first
> to last, I would agree that list is a better representation. If you need
random access, or
> need to do a lot of lookups, an array allows you to sort the data and use
binary search
> quite readily. Then there is the case where neither works well, but a CMap
gives you the
> best compromise. There is no one "right" answer for such a question, but
looking at what
> Jonathan has said, and what I've said, you can decide which is the ideal
representation
> for your problem. Sometimes either choice is "wrong" in that no matter
which choice you
> make, you end up paying a significant performance penalty, and sometimes
it is impossible
> to get really good performance. When this is the case, the CMap often is
the best
> compromise between a pure list and a pure array (but has the property that
the iteration
> order is not guaranteed, so you lose again if the order matters!)
> joe
>
> On Sat, 26 Jun 2004 12:50:03 -0600, "Jonathan Wood"
<jwood@softcircuits.com> wrote:
>
> >It depends on what you are doing. If you are inserting and deleting
elements
> >from your lists, then I would go with CList over CArray no matter how
small
> >your lists are. If you are not inserting and deleting elements, then I'd
use
> >a CArray.
>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages