package hjelpeklasser;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.stream.Stream;
public class SMBinTre<T> implements Beholder<T>
{
private static final class Node<T>
{
private T verdi;
private Node<T> venstre;
private Node<T> høyre;
private int forekomster;
private Node(T verdi, Node<T> v, Node<T> h)
{
this.verdi = verdi;
venstre = v;
høyre = h;
forekomster = 1;
}
private Node(T verdi)
{
this(verdi,null,null);
}
}
private Node<T> rot;
private int antall;
private final Comparator<? super T> comp;
private int endringer;
public SMBinTre(Comparator<? super T> c)
{
rot = null;
antall = 0;
comp = c;
}
public static <T extends Comparable<? super T>> SMBinTre<T> smbintre()
{
return new SMBinTre<>(Comparator.naturalOrder());
}
public static <T> SMBinTre<T> smbintre(Comparator<? super T> c)
{
return new SMBinTre<>(c);
}
public static <T extends Comparable<? super T>> SMBinTre<T> smbintre(Stream<T> s)
{
SMBinTre<T> tre = smbintre();
s.forEach(tre::leggInn);
return tre;
}
public static <T> SMBinTre<T> smbintre(Stream<T> s, Comparator<? super T> c)
{
SMBinTre<T> tre = SMBinTre.smbintre(c);
s.forEach(tre::leggInn);
return tre;
}
@Override
public boolean leggInn(T verdi)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int antall()
{
return antall;
}
@Override
public boolean tom()
{
return antall == 0;
}
@Override
public void nullstill()
{
rot = null;
antall = 0;
endringer++;
}
@Override
public boolean inneholder(T verdi)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean fjern(T verdi)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Iterator<T> iterator()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String toString()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}