Java语言,怎么在产生new对象以后的字典的对象实例中,实现key的重复,怎么颠倒以后重复的保持的实现的机制
没看明白,请详细说下
不知道你这个问题是否已经解决, 如果还没有解决的话:💡设置cur节点遍历链表,当cur.data==key时,删除该节点(特殊极端情况单独考虑)
> 💡
public void remove(int key) {
Node cur=this.head;
while(cur!=null) {
if(cur.data==key) {//如果找到关键字key
if(cur==this.head) {//头节点的data为key
this.head=cur.next;//头节点后移完成头节点删除
if(this.head!=null)//防止空指针异常
this.head.prev=null;
}else {//中间找到key
cur.prev.next=cur.next;
if(cur.next!=null)
cur.next.prev=cur.prev;
else//如果cur.next==null,尾节点即为所需删除节点
this.tail=cur.prev;
}
break;//完成删除后跳出循环
}
cur=cur.next;//如果没有进if语句中,cur继续往后遍历
}
}