SplayTrees and a Dictionary
I'm use a splaytree class as the data storage for the "dictionary".
I have the following to deal with Integers, Objects, etc.:
public class SplayTree<T extends Comparable<? super T>>
And I also have the following:
public class Entry<T> {
public Entry(T word, T def){}
...
}
Which is what I'm using to add a word entry and its definition
But when I try to run some test data, for Ex:
SplayTree<Entry> tree = new SplayTree<Entry>();
tree.insert(new Entry("test", "test"));
I get the following error:
Bound mismatc开发者_JS百科h: The type Entry is not a valid substitute for the bounded parameter > of the type SplayTree
Any idea to what I should do to fix this?
You didn't make class Entry implement Comparable.
public class Entry<T> implements Comparable<T> {
// ...
public int compareTo(final T t) {
// ...
}
}
精彩评论