所以,我有这个函数listOrder(),它检查以确保我的LinkedList符合预期的顺序。但每次我运行它,我都会被一个索引关闭。因此,它期望索引0处的值,但随后它获得索引1处的项,然后循环以期望索引1处的值,但随后它获得索引2处的项.I'我在这里遇到的问题很遗憾。我认为这个问题与我的迭代器类有关。
def post(self):
data = UserRegister.parser.parse_args()
print(data)
cursor = mysql.connect().cursor()
username = request.json['usr_name']
password = request.json['password']
query = "insert into user values(null,'{0}','{1}')".format(username,password)
cursor.execute(query)
return {"message": "User created successfully."}, 201
}
答案 0 :(得分:2)
问题在于您的next
方法,您没有在payload
节点上返回数据(front
)。我建议将其更改为
public T next() throws NoSuchElementException {
T data;
if (current == null) {
throw new NoSuchElementException();
} else {
data = current.payload
current = current.next;
}
return data;
}
public boolean hasNext() {
return current != null;
}