21 26_insertdelete_medium - agarmstrong21/agarmstrong_swd_2019 GitHub Wiki

21-26_InsertDelete_Medium

Portfolio Home Page

Problem Statement

image image image image

User Documentation

InsertDelete is a program that uses Lists and ListNodes to insert and remove ListNodes anywhere in the List. Insert anywhere will take in a place where it is needed to be inserted, then grabbing the previous ListNode, setting its next node to the new node, and setting the next node of the new node to the orginal ListNode's next node. Therefore putting it in the middle of the two nodes.

Remove anywhere takes a place where a node needs to be removed, finds it, and take the previous node's nextNode equal to its next nextNode, then changing its old nextNode to null and changing it's nextNode to null too. Returning the data of the removed node.

Developer Documentation

In ListTest, the methods are called as removeAt and insertAt. removeAt takes in the position of the node, for loops to the node previous of the removed Node, then sets the nextNode of that node to the next's nextNode, thus skipping a Node. Setting the nextNode of the removed Node to null and returning the data of the removed Node.

insertAt takes in the Node data and the position of where it needs to be inserted. Finds the node previous to the spot it needs to be, sets the nextNode of that node to the new Node, then setting the nextNode of the new Node to the previous Node's original nextNode. Thus having inserted the Node.

Java Docs

The java documents are served from a local web server on this machine. To start the web server, navigate to the directory immediately above where the source code is checked out (i.e. ~/git ) and then use "python -m SimpleHTTPServer" in that directory.

cd ~/git python -m SimpleHTTPServer&

Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:

python3 -m http.server

Java Docs for 21-26_InsertDelete_Medium

Source Code

Source Code for 21-26_InsertDelete_Medium