如何在链表中做天花板?

时间:2016-04-09 02:07:10

标签: java symbol-table

我无法弄清楚如何返回符号表中大于或等于键的最小键...如果有人可以指向正确的方向,那将是很好的因为我不知道从哪里开始

public class LinkedListST<Key extends Comparable<Key>, Value> {
    private Node first; 

    // a helper linked list data type
    private class Node {
        private Key key;
        private Value val;
        private Node next;

    public Node(Key key, Value val, Node next)  {
        this.key  = key;
        this.val  = val;
        this.next = next;
    }
}

 public Key ceiling (Key key) {
    Key ceiling = null;
    for(Node x = first; x != null; x = x.next){
        if(first.key.compareTo(ceiling) > 0)
            ceiling = key; 
    }
    return null; //TODO
}

0 个答案:

没有答案