0

降順で作成されるはずのヘッダー リンク リストがある場合、コンパレータを使用して現在のノードと新しいノードを比較して追加するにはどうすればよいですか?

priorityComparator.compare(e, temp.next.value) を使用しますか?

public boolean add (E e) {
  //front always points to the header.
  final ListNode<E> front = highest;
  ListNode<E> temp = front;

  ListNode<E> newNode = new ListNode<E>(e, null);

  //Insert to front if header points to null.
  if (temp.next == null){
      temp.next = newNode;
  }
  //how to add in sorted order?


return true;
}
4

0 に答える 0