ps3.graph
Class WeightedNode
java.lang.Object
ps3.graph.WeightedNode
- All Implemented Interfaces:
- Comparable<WeightedNode>
public class WeightedNode
- extends Object
- implements Comparable<WeightedNode>
A WeightedNode class is a simple record type which contains a name
and a cost
name
public final String name
cost
public final int cost
WeightedNode
public WeightedNode(String name,
int cost)
- Constructs a new WeightedNode.
- Effects:
- constructs a new WeightedNode with the name
name
and the cost cost
.
name
public String name()
- Returns:
- this.name
cost
public int cost()
- Returns:
- this.cost
equals
public boolean equals(Object o)
- Overrides:
equals
in class Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
toString
public String toString()
- Overrides:
toString
in class Object
compareTo
public int compareTo(WeightedNode o)
- WeightedNodes are ordered lexicographically by their name. When
two nodes share a name, their ordering is determined by the
numeric ordering of their costs.
- Specified by:
compareTo
in interface Comparable<WeightedNode>