Ary Borenszweig:

So the doubly linked list doesn't know it's length? That seems a bit inefficient...

Have you tried to compile mydList.length or mydList[].length? If both don't compile, then you have to walk the items.

Walking the items is not efficient, but:
- Linked lists are very uncommonly needed. In 98-99% of cases an array of items or an array of pointers is better (faster for all operations, more efficient for memory used, leading to smaller binary, more compatible with other APIs, and so on). - Most functional algorithms that work on lists do not need to know the length of the list.

Bye,
bearophile

Reply via email to