A "header" node for MList
s.
The info
field stores information about the list, such as its length.
The front
field stores a pointer to the front of the list. Maintaining
this pointer in a header node helps avoid a very common bug where the
front of the list changes (either a new list node was added or the front
node was removed) but a pointer elsewhere in the code still points
to the old front. With header nodes, only pointers to the header should
be shared, and every operation that changes the front of the list
should update the header.
- Companion:
- object
class Object
trait Matchable
class Any