Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

what's the difference between CList and CArray ??

1 view
Skip to first unread message

Ake

unread,
Mar 7, 2001, 6:55:09 PM3/7/01
to
When programming in C i knew that an array was a fixed length collection of
elements, whilst a list was something created dynamically and it didn't
require to know its dimension at creation time.Now reading the docs about
CArray and CList they seem to be both dynamical structures...so what's the
difference between them? The docs say that traversing the List could slow
down the process if the list is long....but wasn't speed one of the positive
things in using a list against an array? and wouldn't be the same if you had
to scan a large array?
--
Visita la mia pagina personale:
http://members.xoom.it/Ake
*** grafica - ingegneria - midi - humour ***
**** abandonware - emulatori - MUD ****
*** DragonBall / Z ****
Il Covo di Ake ora e' anche senza fili,
visitalo con il tuo cellulare WAP a:
tagtag.com/ake


Scott McPhillips

unread,
Mar 7, 2001, 10:33:35 PM3/7/01
to
Ake wrote:
>
> When programming in C i knew that an array was a fixed length collection of
> elements, whilst a list was something created dynamically and it didn't
> require to know its dimension at creation time.Now reading the docs about
> CArray and CList they seem to be both dynamical structures...so what's the
> difference between them? The docs say that traversing the List could slow
> down the process if the list is long....but wasn't speed one of the positive
> things in using a list against an array? and wouldn't be the same if you had
> to scan a large array?

The elements of an array (including CArray) can be accessed randomly with an
index. That is very fast. A list (including CList) cannot be accessed randomly
at all - it is necessary to scan through it sequentially to access an element.
Use arrays for fast random access, use lists for fast insertion or removal of
elements.

--
Scott McPhillips [VC++ MVP]

Tim Slattery

unread,
Mar 8, 2001, 9:14:42 AM3/8/01
to
Scott McPhillips <scot...@REMOVETHIShome.com> wrote:

Right. Each element of a list contains a pointer to the next item
(single list) or to both the previous and next items (double-linked).
If you need the fiftieth element, you have to traverse the previous
forty-nine to get it. With a table you can simply calculate the
address of the fiftieth element and go directly there.


--
Tim Slattery
Slatt...@bls.gov

0 new messages