84 lines
1.5 KiB
Java
84 lines
1.5 KiB
Java
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.ArrayList;
|
|
|
|
public class Node
|
|
{
|
|
private Node left;
|
|
private Node right;
|
|
private int anzahl;
|
|
private Character buchstabe;
|
|
|
|
public Node()
|
|
{
|
|
}
|
|
|
|
public Node(Node left, Node right)
|
|
{
|
|
this.left = left;
|
|
this.right = right;
|
|
}
|
|
|
|
public Node getLeft()
|
|
{
|
|
return left;
|
|
}
|
|
|
|
public Node getRight()
|
|
{
|
|
return right;
|
|
}
|
|
|
|
public void setLeft(Node left)
|
|
{
|
|
this.left = left;
|
|
}
|
|
|
|
public void setRight(Node right)
|
|
{
|
|
this.right = right;
|
|
}
|
|
|
|
public int getAnzahl()
|
|
{
|
|
return anzahl;
|
|
}
|
|
|
|
public Character getBuchstabe()
|
|
{
|
|
return buchstabe;
|
|
}
|
|
|
|
public void setAnzahl(int anzahl)
|
|
{
|
|
this.anzahl = anzahl;
|
|
}
|
|
|
|
public void setBuchstabe(Character buchstabe)
|
|
{
|
|
this.buchstabe = buchstabe;
|
|
}
|
|
|
|
public static Node erstellen(Map<Character, Integer> häufigkeiten)
|
|
{
|
|
ArrayList<Node> nodes = new ArrayList<Node>();
|
|
|
|
for (Map.Entry<Character, Integer> entry : häufigkeiten.entrySet())
|
|
{
|
|
Character character = entry.getKey();
|
|
int anzahl = entry.getValue();
|
|
}
|
|
|
|
while (nodes.size() > 1)
|
|
{
|
|
Node min1 = nodes.get(1);
|
|
|
|
for (Node node : nodes)
|
|
{
|
|
//if(node.getCount() < min1.getCount())
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|