Home Segments Index Top Previous Next

740: Mainline

Thus, to access the elements in a list, you have your program use advance to move current_link_pointer:

A header object 
*-------* 
|       | --*   ----*   ------------*      The current_link_pointer 
|-------|   |       |               |      moves down the list 
|       |   |       |               | 
*-------*   |       |               | 
    |       |       |               | 
    |  *----*       |               | 
    |  |            |               | 
    v  v            v               v 
*-------*       *-------*       *-------*  Three link objects 
|       | ----> |       | ----> |   0   |   
|-------|       |-------|       |-------| 
|       |       |       |       |       | 
*-------*       *-------*       *-------*  
    |               |               | 
    v               v               v 
*-------*       *-------*       *-------*  Three railroad_car objects 
|       |       |       |       |       | 
|-------|       |-------|       |-------| 
|       |       |       |       |       | 
|-------|       |-------|       |-------| 
|       |       |       |       |       | 

As your program moves current_link_pointer along, it can access elements using access until endp determines that there are no more elements. Then, your program can use reset to return current_link_pointer to its original position.