Putting elements from arrayList to TreeSet not possible?
hi,
i am really thinking about this for an hour now, but i have no idea why the following code is not working where i just initialize some vertices of a graph
with an id and now i want those to be inserted into an TreeSet. But some
of those vertices are not inserted to the set....(each vertice holds a weight
of default 10000 for the comparison in the TreeSet)
Graph.java:
publicclass Graph{
privatestatic String verticesId[] =new String[]{"S","U","V","Y","X"};
privatestatic List<Vertice> vertices =new ArrayList<Vertice>(verticesId.length);
//init the vertices
for(int i=0;i<verticesId.length;i++)
vertices.add(i,new Vertice(verticesId[i]));
//return the initialized vertices
publicstatic List getVertices(){
return vertices;
}
}
now, in Algorithm.java where i use these initialized vertices:
public Algorithm(){
verticeQueue =new TreeSet><Vertice>(graph.getVertices());
System.out.println(verticeQueue.size());// delivers only 2 but at least 5 are
//existing. What did happen here?
I also tried to put in the vertices manually, by
List<Vertice> list = graph.getVertices();
for(Vertice v: list){
System.out.println("Putting in "+v.getId());//thats ok
verticeQueue.add(v);//but it is not inserted? Why?
}
but it is the same problem. Some elements are just missing - but they are
existing in the ArrayList (test output shows it)
Can anybody help me to solve this? Thanks in advance!

