Skip to content
Snippets Groups Projects
Commit f0bf6302 authored by Christopher Schankula's avatar Christopher Schankula :earth_africa:
Browse files

fixed Red-Black put() existing value, fix Main.java

parent 7742bcbc
No related branches found
No related tags found
No related merge requests found
UML.png

853 KiB | W: | H:

UML.png

853 KiB | W: | H:

UML.png
UML.png
UML.png
UML.png
  • 2-up
  • Swipe
  • Onion skin
No preview for this file type
......@@ -161,7 +161,7 @@ Secondly, this diagrams represents a key feature of \textit{TrawlExpert} in that
\begin{figure}[H]
\includegraphics[width=18cm, trim={6cm 0 6cm 0}, clip]{MainDotJava.pdf}
\caption{UML State machine diagram for \textit{Main.java}, a class that provides console access to the \textit{TrawlExpert}'s main functions. This class accepts search criteria from a user to produce a list of search results, depict a histogram of the records in that result, and compute a count of the search hits.}
\caption{UML State machine diagram for \textit{main/Main.java}, a class that provides console access to the \textit{TrawlExpert}'s main functions. This class accepts search criteria from a user to produce a list of search results, depict a histogram of the records in that result, and compute a count of the search hits.}
\label{fig:MainUML}
\end{figure}
......@@ -169,7 +169,7 @@ Secondly, this diagrams represents a key feature of \textit{TrawlExpert} in that
\centering
\includegraphics[width=18cm, trim={0 0 0 0}, clip]{BioTreeDotJava.pdf}
\caption{UML State machine diagram for \textit{/data/Biotree/BioTree.java}, a class that builds a tree data structure from the scientific name hierarchies (called taxa) of fish. Uses a World Register of Marine Species (Worms) API to identify the correct spelling of species names for misspelled scientific names in the dataset. }
\caption{UML State machine diagram for \textit{/data/biotree/BioTree.java}, a class that builds a tree data structure from the scientific name hierarchies (called taxa) of fish. Uses a World Register of Marine Species (Worms) API to identify the correct spelling of species names for misspelled scientific names in the dataset. }
\label{fig:BioTreeUML}
\end{figure}
......
......@@ -28,7 +28,7 @@ public class Main {
/**
* The main method to start up the program.
*/
public static void main() {
public static void main(String[] args) {
printLogo();
te = new TrawlExpert();
init();
......
......@@ -11,7 +11,7 @@ import java.io.Serializable;
*/
class RBNode<Key extends Comparable<Key>, Value> implements Serializable{
private final Key key;
private Value val;
Value val;
private RBNode<Key, Value> left, right;
private int n;
private boolean color;
......
......@@ -108,14 +108,14 @@ public class RedBlackTree<Key extends Comparable<Key>, Value> implements Seriali
int cmp = compare.compare(newNode.key(), h.key());
if (cmp < 0 && (h.left() == null))
h.left(newNode);
else if (cmp < 0 )
else if (cmp < 0)
h.left(put(h.left(), newNode));
else if (cmp > 0 && (h.right() == null))
h.right(newNode);
else if (cmp > 0)
h.right(put(h.right(), newNode));
else
h = newNode;
h.val = newNode.val;
// Rearrange the tree to maintain balance
if(h.n() > 2){
......@@ -239,10 +239,10 @@ public class RedBlackTree<Key extends Comparable<Key>, Value> implements Seriali
* @param results The ArrayList to populate the keys with.
* @return An ArrayList of keys in this subtree.
*/
private ArrayList<Key> keys(RBNode x, ArrayList<Key> results){
private ArrayList<Key> keys(RBNode<Key,Value> x, ArrayList<Key> results){
if (x == null) return results;
keys(x.left(), results);
results.add((Key) x.key());
results.add(x.key());
keys(x.right(), results);
return results;
}
......
......@@ -11,7 +11,7 @@ public class Histogram {
*
* @param record
* - An iterable of records
* @return - The BST
* @return - The Red-Black tree representing the histogram (key - year, value - individual count)
*/
public static RedBlackTree<Integer, Integer> histogram(Iterable<Record> record) {
RedBlackTree<Integer, Integer> tree = new RedBlackTree<Integer, Integer>(a -> 0, (n0, n1) -> n0.compareTo(n1));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment