Call the Generic parameterized method in java -
what error mesaage meant , how call generic parameterized method class: following error message:
the method add(int, integer) in type binaryminheap<integer> not applicable arguments (int, vertex<integer>)
calling snippet:
for(vertex<integer> vertex : graph.getallvertex()){ minheap.add(integer.max_value, vertex); }
method being called is:
public void add(int weight,t key) { node node = new node(); node.weight = weight; node.key = key; allnodes.add(node); int size = allnodes.size(); int current = size - 1; int parentindex = (current - 1) / 2; nodeposition.put(node.key, current); while (parentindex >= 0) { node parentnode = allnodes.get(parentindex); node currentnode = allnodes.get(current); if (parentnode.weight > currentnode.weight) { swap(parentnode,currentnode); updatepositionmap(parentnode.key,currentnode.key,parentindex,current); current = parentindex; parentindex = (parentindex - 1) / 2; } else { break; } } }
i'm not sure trying accomplish, cannot pass vertex<integer>
takes integer
. if want add every element of vertex
, use nested loop. otherwise have map vexter<integer>
integer
somehow.
see method signature: binaryminheap<integer>.add(int, integer)
however, trying call vertex<integer> vertex
that: add(int, vertex<integer>)
, not applicable (as stated in error)
Comments
Post a Comment