2010/4/9 Leinier Cruz Salfran <salfrancl.lis...@gmail.com>

> - use a matrix is faster than use a linked list?
>
> example:
>
> char *szColumnName[10];
> unsigned short iColumnAge[10];
>
>
> struct _llList {
>  struct _llList *prev, *next;
>  char szName[64];
>  unsigned short iAge;
>  };


Leinier ,

This depends on what kind of operations are performed. For sequential
traversing, both are very appropriate. However, you can not perform a binary
search on a list. You also can not combine two arrays into a single one with
constant complexity.

Lists also have greater memory overhead for small structures.

My advice: always use arrays.
Use lists if:

1) Copying items when the dynamic arrays grows is inappropriate.
2) List-specific operations like O(1) splicing or O(1) insertions and
deletions are required.

Alexander Churanov
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to