文字列を二重連結リストに逆の順序で挿入しようとしています。しかし、挿入順序を逆順に維持する方法がわかりません。
これは私の以下のコードです。
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;
}
私のソリューションに基づいたいくつかのコードを使用して、任意の提案をいただければ幸いです..