public class Node<< K extends ObjectId, W extends Sum<W> & Comparable<W>>> {
public K key;
public ListItem<Edge<K, W>> headEdges;
public Node(K key) {
this.key = key;
}
`Node class`
}
public interface ObjectId {
/**
* @return ObjectId for this object
*/
public String getObjectId();
}
`interface ObjectId`
public class Graph<< K extends ObjectId, W extends Sum<W> & Comparable< W> > {
public ListItem<Node<K, W>> head;
public void connectNodes(String idFrom, String idTo, W weight) {
Node<K, W> f = null;
Node<K, W> t=null;
for ( ListItem<Node<K, W>> p = head; p != null; p = p.next )
{
K s = p.key.key;
if(s.getObjectId()==idFrom)
f=p.key;}
}}
如果K等于idFrom,则在列表中搜索。
我不知道如何使用getObjectId()
。