Skip to content

Instantly share code, notes, and snippets.

@b-adams
Created March 19, 2012 07:05
Show Gist options
  • Save b-adams/2100108 to your computer and use it in GitHub Desktop.
Save b-adams/2100108 to your computer and use it in GitHub Desktop.
Documentation and sample output for Linked List program.
//This documentation should be put with the appropriate class/method/function declarations.
//Remember to add file documentation blocks to all your files!
/**
Entry point for the program. Tests that list operations are working.
*/
/**
Represents a node in a singly linked list
*/
/**
Payload of the node
*/
/**
Next node (nil if no next node)
*/
/**
Represents a singly linked list
*/
/**
Represents a singly linked list
*/
/**
First element (head, handle) of the list
*/
/**
Removes the first element from the list
/returns (a pointer to) the removed node
*/
/**
Removes an element from the middle of the list
/param preTarg The element before the element to remove
/returns (a pointer to) the removed node
*/
/**
Inserts an element into the middle of the list
/param newDatum The value that should go in the new element
/param preTarg The element before where you want the new one
/returns (a pointer to) the inserted node
*/
/**
Inserts an element at the beginning of the list
/param newDatum The value that should go in the new element
/returns (a pointer to) the inserted node
*/
/**
Sets up an empty list (the head is nil)
/returns (a pointer to) the initialized object
*/
/**
Create a string whose first character is the first character of the list, second is second, etc.
/returns the letters in the list condensed to a single string.
*/
/**
Locate the node before a given node
/param postTarg The node we're trying to look in front of
/returns (a pointer to) the node before postTarg, or nil for the head
*/
/**
Locate the node at a given index
/param index How many steps to travel from the head
/returns (a pointer to) the node index-many steps from the head, or nil if list too small.
*/
/**
Locate A node containing the given datum
/param findThis The datum to search for
/returns (a pointer to) some node containing findThis as its payload
*/
/**
Calculate the number of elements in the list
/returns how many elements are in the list
*/
/**
Determines if a datum is in the list
/param findThis The datum we're trying to look for
/returns YES if findThis occurs at least once in the list, NO if not.
*/
2012-03-19 03:02:46.613 cs132_program_LinkedLists_FLAST[21312:403] First contains: <Prof>
2012-03-19 03:02:46.618 cs132_program_LinkedLists_FLAST[21312:403] Last contains: <Adams>
2012-03-19 03:02:46.620 cs132_program_LinkedLists_FLAST[21312:403] Full contains: <ProfAdams>
2012-03-19 03:02:46.624 cs132_program_LinkedLists_FLAST[21312:403] Full contains: <ProfBAdams>
2012-03-19 03:02:46.625 cs132_program_LinkedLists_FLAST[21312:403] First has <ProfBAdams> Last has <Adams>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment