In 'Principles and Practice Using C++' Stroustrup implements a linked list without a pointer to the head of the list, just a current-position-pointer (chapter 17.9.3, second edition). Note that the list is not circular. For me this feels rather like a disadvantage, for example when printing all elements, we have to move a new pointer to the head in order to iterate through all nodes.
Is there some design-disadvantage of using a head-pointer within linked lists?
Aucun commentaire:
Enregistrer un commentaire