![]() |
![]() |
![]() |
![]() |
![]() |
|
The work done by add involves several pointers. As an illustration
of how add works, suppose that you want to add a third element onto
a two-element list. First, add must create a new link object
with pointers to the old first element and to the new
object:
New | Old
| *-------* A header object
| | |
| *-------*
| | |
| *-------*
| |
| v
*-------* | *-------* *-------* link
| | --------------------> | | ----> | 0 | objects
|-------| | |-------| |-------|
| | | | | | |
*-------* | *-------* *-------*
| | | |
v | v v
*-------* | *-------* *-------* railroad_car
| | | | | | | objects
|-------| | |-------| |-------|
| | | | | | |
|-------| | |-------| |-------|
| | | | | | |