mirror of
https://github.com/RustyRaptor/CS-272.git
synced 2026-12-03 15:55:22 -07:00
Added proper README.md
This commit is contained in:
1 parent
bca08de57e
commit
6c9e4dc679
3 files changed
+194
-1
No files matched your search
@@ -0,0 +1 @@
|
||||
https://github.com/RustyRaptor/CS-272.git
|
||||
+21
-1
@@ -101,7 +101,7 @@ public class IntNode {
|
||||
if (head == null) {
|
||||
return 0;
|
||||
}
|
||||
int cnt = 0;
|
||||
int cnt = 1;
|
||||
for (IntNode cursor = head.getLink(); cursor != null; cursor
|
||||
= cursor.getLink()){
|
||||
cnt++;
|
||||
@@ -110,6 +110,26 @@ public class IntNode {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns number of even numbers in the list starting from "head" node
|
||||
* @param head the node to start from.\
|
||||
* @return integer
|
||||
*/
|
||||
public static int listEvenNumber(IntNode head) {
|
||||
if (head == null) {
|
||||
return 0;
|
||||
}
|
||||
int cnt = 1;
|
||||
for (IntNode cursor = head.getLink(); cursor != null; cursor
|
||||
= cursor.getLink()){
|
||||
if (cursor.data%2 == 0) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* searches for a data input and returns whether or not it exists in
|
||||
* the List
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* A set of functions to test all the features of IntNode
|
||||
* also includes a testAll(); function just to run them some more because why
|
||||
* not.
|
||||
*/
|
||||
|
||||
public class IntNodeAdvancedTest {
|
||||
/**
|
||||
* This main function just runs all the test functions.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
IntNodeAdvancedTest.testAddNodeAfterThis();
|
||||
IntNodeAdvancedTest.testAddRangeAfterThis();
|
||||
IntNodeAdvancedTest.testPrintData();
|
||||
IntNodeAdvancedTest.testRemoveNodeAfterThis();
|
||||
IntNodeAdvancedTest.testTestToString();
|
||||
IntNodeAdvancedTest.testSearch();
|
||||
IntNodeAdvancedTest.testAll();
|
||||
}
|
||||
|
||||
|
||||
private static void testAddRangeAfterThis() {
|
||||
IntNode myNode = new IntNode();
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.getLink().getLink().getLink().getLink()
|
||||
.addRangeAfterThis(100,200);
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.addRangeAfterThis(1000, 1100);
|
||||
myNode.getLink().getLink().addRangeAfterThis(1000, 1100);
|
||||
|
||||
}
|
||||
private static void testListEvenNumber() {
|
||||
IntNode myNode = new IntNode();
|
||||
System.out.println(IntNode.listEvenNumber(myNode));
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
System.out.println(IntNode.listEvenNumber(myNode));
|
||||
myNode.getLink().getLink().getLink().getLink()
|
||||
.addRangeAfterThis(100,200);
|
||||
System.out.println(IntNode.listEvenNumber(myNode));
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
System.out.println(IntNode.listEvenNumber(myNode));
|
||||
myNode.addRangeAfterThis(1000, 1100);
|
||||
System.out.println(IntNode.listEvenNumber(myNode));
|
||||
myNode.getLink().getLink().addRangeAfterThis(1000, 1100);
|
||||
System.out.println(IntNode.listEvenNumber(myNode));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void testAddNodeAfterThis() {
|
||||
IntNode myNode = new IntNode();
|
||||
myNode.addNodeAfterThis(22);
|
||||
myNode.addNodeAfterThis(22);
|
||||
myNode.addNodeAfterThis(1000);
|
||||
myNode.addNodeAfterThis(-1000);
|
||||
myNode.addNodeAfterThis(-2000);
|
||||
myNode.addNodeAfterThis(0);
|
||||
}
|
||||
|
||||
|
||||
private static void testRemoveNodeAfterThis() {
|
||||
IntNode myNode = new IntNode();
|
||||
myNode.removeNodeAfterThis();
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.removeNodeAfterThis();
|
||||
}
|
||||
|
||||
|
||||
private static void testTestToString() {
|
||||
IntNode myNode = new IntNode();
|
||||
System.out.println(myNode.toString());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void testPrintData() {
|
||||
IntNode myNode = new IntNode();
|
||||
System.out.println(myNode.toString());
|
||||
myNode.printData();
|
||||
myNode.addNodeAfterThis(22);
|
||||
myNode.printData();
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.printData();
|
||||
myNode.removeNodeAfterThis();
|
||||
myNode.removeNodeAfterThis();
|
||||
myNode.printData();
|
||||
myNode.removeXNodesAfterThis(100);
|
||||
myNode.printData();
|
||||
}
|
||||
|
||||
private static void testAll() {
|
||||
IntNode myNode = new IntNode();
|
||||
IntNodeAdvancedTest.testSearch();
|
||||
System.out.println(myNode.toString());
|
||||
System.out.println("Testing toString with Null");
|
||||
myNode.printData();
|
||||
myNode.addNodeAfterThis(22);
|
||||
System.out.println("Testing Add Node After This");
|
||||
myNode.printData();
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
System.out.println("Testing add range");
|
||||
myNode.printData();
|
||||
myNode.removeNodeAfterThis();
|
||||
myNode.removeNodeAfterThis();
|
||||
System.out.println("Testing Remove Node After THis");
|
||||
myNode.printData();
|
||||
myNode.removeXNodesAfterThis(100);
|
||||
System.out.println("Testing Remove X Nodes");
|
||||
myNode.printData();
|
||||
System.out.println(myNode.toString());
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.addRangeAfterThis(1000, 1100);
|
||||
myNode.getLink().getLink().addRangeAfterThis(1000, 1100);
|
||||
myNode.removeNodeAfterThis();
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.removeNodeAfterThis();
|
||||
myNode.addNodeAfterThis(22);
|
||||
myNode.addNodeAfterThis(22);
|
||||
myNode.addNodeAfterThis(1000);
|
||||
myNode.addNodeAfterThis(-1000);
|
||||
myNode.addNodeAfterThis(-2000);
|
||||
myNode.addNodeAfterThis(0);
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
System.out.println(myNode.toString());
|
||||
IntNodeAdvancedTest.testAddNodeAfterThis();
|
||||
IntNodeAdvancedTest.testAddRangeAfterThis();
|
||||
System.out.println("Testing toString()");
|
||||
System.out.println(myNode.toString());
|
||||
IntNodeAdvancedTest.testPrintData();
|
||||
IntNodeAdvancedTest.testRemoveNodeAfterThis();
|
||||
IntNodeAdvancedTest.testTestToString();
|
||||
}
|
||||
|
||||
private static void testSearch() {
|
||||
IntNode myNode = new IntNode();
|
||||
IntNode bools = new IntNode();
|
||||
for (int i = 0; i < 100000; i++){
|
||||
IntNode.search(myNode, i);
|
||||
|
||||
}
|
||||
|
||||
myNode.addNodeAfterThis(22);
|
||||
myNode.addNodeAfterThis(22);
|
||||
myNode.addNodeAfterThis(1000);
|
||||
myNode.addNodeAfterThis(-1000);
|
||||
myNode.addNodeAfterThis(-2000);
|
||||
myNode.addNodeAfterThis(0);
|
||||
for (int i = 0; i < 100000; i++){
|
||||
IntNode.search(myNode, i);
|
||||
|
||||
}
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.getLink().getLink().getLink().getLink()
|
||||
.addRangeAfterThis(100,200);
|
||||
myNode.addRangeAfterThis(0, 100);
|
||||
myNode.addRangeAfterThis(1000, 1100);
|
||||
myNode.getLink().getLink().addRangeAfterThis(1000, 1100);
|
||||
for (int i = 0; i < 100000; i++){
|
||||
if (IntNode.search(myNode, i)) {
|
||||
bools.addNodeAfterThis(1);
|
||||
} else{
|
||||
bools.addNodeAfterThis(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
System.out.println("test search results");
|
||||
bools.printData();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user