User Tools

Site Tools


haas:fall2018:data:projects:sll0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:fall2018:data:projects:sll0 [2018/09/10 13:15] wedgehaas:fall2018:data:projects:sll0 [2018/09/11 12:53] (current) – [Background] wedge
Line 26: Line 26:
 There are, however, many distinctions of linked lists... so we tend to add on a lot of qualifiers to better identify the particular type of linked list we are implementing/using. There are, however, many distinctions of linked lists... so we tend to add on a lot of qualifiers to better identify the particular type of linked list we are implementing/using.
  
-As our nodes up to this point have only contained a single Node pointer for connection (the "to" pointer), we have what are called "singly-linked nodes".+As our nodes up to this point have only contained a single Node pointer for connection (the "right" pointer), we have what are called "singly-linked nodes".
  
 Therefore, generically, we are creating a "Singly-Linked List"; but we should also be specific about what we are creating a singly-linked list of-- so the full description will be "List of Singly-Linked Nodes". Therefore, generically, we are creating a "Singly-Linked List"; but we should also be specific about what we are creating a singly-linked list of-- so the full description will be "List of Singly-Linked Nodes".
Line 45: Line 45:
 <code c> <code c>
 struct list { struct list {
-    struct node *engine+    struct node *lead
-    struct node *caboose;+    struct node *last;
 }; };
 </code> </code>
Line 66: Line 66:
     Node *tmp    = mknode(7);     Node *tmp    = mknode(7);
          
-    myList = insert(myList, myList -> engine, tmp); // insert tmp before initial node of myList+    myList = insert(myList, myList -> lead, tmp); // insert tmp before initial node of myList
 </code> </code>
  
-And we can access the value contained in the list's initial node as follows: myList -> engine -> contents+And we can access the value contained in the list's initial node as follows: myList -> lead -> info
  
 We do need to be mindful of the organization we are creating- as part of implementing this, we'll have various list management functions at our disposal (insert, append, sort, getpos, obtain, etc.)... so we should restrict our list manipulation to those functions (reduce the number of cooks in the kitchen). This is another aspect of relinquishing our default tight fist of control... it may take some getting used to, but as you start seeing the bigger picture, you'll see what a big favor we're doing for ourselves here. We do need to be mindful of the organization we are creating- as part of implementing this, we'll have various list management functions at our disposal (insert, append, sort, getpos, obtain, etc.)... so we should restrict our list manipulation to those functions (reduce the number of cooks in the kitchen). This is another aspect of relinquishing our default tight fist of control... it may take some getting used to, but as you start seeing the bigger picture, you'll see what a big favor we're doing for ourselves here.
Line 288: Line 288:
  
 struct list { struct list {
-    Node *engine                      // pointer to start of list +    Node *lead                        // pointer to start of list 
-    Node *caboose                     // pointer to end of list+    Node *last                        // pointer to end of list
 }; };
 typedef struct list List;               // because we deserve nice things typedef struct list List;               // because we deserve nice things
haas/fall2018/data/projects/sll0.1536585323.txt.gz · Last modified: 2018/09/10 13:15 by wedge