我正在编写一个小型Java应用程序,在其中应该可以执行以下操作:
当前正在使用HashMap来存储创建的节点,但认为其中缺少某些内容。 在修订中,它应该复制所有详细信息,并且id应该增加,而修订版id也应该增加。
public class NodeList {
Node head;
static class Node{
private int id;
private String name;
private int value;
private int revision;
private int parentRevision;
private int childIdOne;
private int childIdTwo;
Node nextReivision;
public Node() {
super();
}
Node(int id, String name, int value) {
this.id = id;
this.name = name;
this.value= value;
this.revision = 1;
this.parentRevision = -1;
this.childIdOne = -1;
this.childIdTwo = -1;
nextReivision = null;
} // Constructor
public Node(int id, String revisedName, int revisedValue, int revisedRevisionId) {
// TODO Auto-generated constructor stub
System.out.println("in 3 arg constructor " + revisedName + revisedValue + revisedRevisionId);
this.id = id;
this.name = revisedName;
this.value= revisedValue;
this.revision = revisedRevisionId;
this.parentRevision = -1;
this.childIdOne = -1;
this.childIdTwo = -1;
nextReivision = null;
}
}