📄 vertexweightpair.java
字号:
public class VertexWeightPair implements Comparable {
Vertex to; // the "from" vertex is implicit
double weight;
// Postcondition: this VertexWeightPair has been initialized from vertex and weight.
public VertexWeightPair (Vertex vertex, double weight) {
to = vertex;
this.weight = weight;
} // default constructor
// Postcondition: the "to" vertex in this VertexWeightPair has been returned.
public Vertex getToVertex() {
return to;
} // method getToVertex
// Postcondition: the weight in this VertexWeightPair has been returned.
public double getWeight() {
return weight;
} // method getWeight
// Postcondition: an int <, = or > 0 has been returned, depending on
// whether this VertexWeightPair's weight is <, = or >
// VertexWeightPair's weight.
public int compareTo (Object vertexWeightPair) {
Double thisWeight = new Double(weight);
Double otherWeight = new Double(((VertexWeightPair)vertexWeightPair).getWeight());
return thisWeight.compareTo(otherWeight);
} // method compareTo
// Postcondition: a String representation of this VertexWeightPair
// has been returned.
public String toString() {
return to.toString() + " " + String.valueOf (weight);
} // method toString
} // class VertexWeightPair
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -