Commit 6da8ebcb authored by michael lundquist's avatar michael lundquist
Browse files

The Doubly linked classes now work, but still aren't commented.

parent 849256d4
Pipeline #3989 passed with stage
in 1 minute and 18 seconds
...@@ -2,10 +2,11 @@ package com.ds.fourthassignment; ...@@ -2,10 +2,11 @@ package com.ds.fourthassignment;
/** /**
* This now supports the scientist type * This now supports the scientist type
*
* @author Michael Lundquist
*/ */
public class DoublyLNode { public class DoublyLNode {
private Scientist data; private Scientist data;
private DoublyLNode next; private DoublyLNode next;
private DoublyLNode previous; private DoublyLNode previous;
......
package com.ds.fourthassignment; package com.ds.fourthassignment;
/**
*
* @author Michael Lundquist
*/
public class DoublyLinkedList { public class DoublyLinkedList {
private DoublyLNode head; private DoublyLNode head;
...@@ -91,17 +95,16 @@ public class DoublyLinkedList { ...@@ -91,17 +95,16 @@ public class DoublyLinkedList {
* @return the index of this scientist, or -1 * @return the index of this scientist, or -1
*/ */
public int indexOfElement(Scientist s){ public int indexOfElement(Scientist s){
DoublyLNode curNode = head;
int curIndex = 0; int curIndex = 0;
do{ for(
DoublyLNode curNode = this.head;
curNode != null;
curIndex ++, curNode = curNode.getNext()
){
if(curNode.getData().compareTo(s) == 0){ if(curNode.getData().compareTo(s) == 0){
return curIndex; return curIndex;
} }
curNode = curNode.getNext(); }
curIndex ++;
} while(curNode.hasNext());
return -1; return -1;
} }
} }
\ No newline at end of file
package com.ds.fourthassignment; package com.ds.fourthassignment;
/**
*
* @author Michael Lundquist
*/
public class LNode { public class LNode {
Integer data; Integer data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment