【发布时间】:2012-02-18 02:08:46
【问题描述】:
我想以相反的顺序将字符串插入双向链表。但我不确定如何以相反的顺序维护插入顺序。
这是我下面的代码。
theList.insertReverseLexicographicalOrder("B");
theList.insertReverseLexicographicalOrder("A");
theList.insertReverseLexicographicalOrder("H");
theList.insertReverseLexicographicalOrder("D");
theList.insertReverseLexicographicalOrder("E");
public void insertReverseLexicographicalOrder(String dd) {
Link newLink = new Link(dd);
if (isEmpty()){
last = newLink;
}
first.previous = newLink;
}
newLink.next = first;
first = newLink;
}
任何建议都将根据我的解决方案使用一些代码表示赞赏..
【问题讨论】: