iam должен отображать записи клиентов из txt-файла, а затем повторно отображать их в порядке возрастания. У меня есть первая часть, но я не могу определить сортировку. Вот что я имею под метод общественного недействительными добавить (newNode клиентов, внутр фиктивная)сортировать реализованный список ссылок
public void add(Customer newNode, int dummy)
{
if (head == null) // The first node
{
head = tail = this;
head.setData(newNode); size=1;
return;
} //************need to figure this out
CustomerList t = new CustomerList();
head.setNext(temp);
getHead().getNext();
head = temp;
//this is the part am trying to figure out
++size;
} // add
// Append the new node to the end of list
public void add(Customer newNode)
{
if (head == null) // The first node
{
head = tail = this;
head.setData(newNode);
size=1;
return;
}
CustomerList temp = new CustomerList(newNode);
tail.setNext(temp);
getHead().getNext();
tail = temp;
++size;
} // add
// retrieve a specific node by index
// The index starts with 0
public Customer get(int which)
{
if (which > size-1)
return null;
if (size < 0)
return null;
CustomerList temp = head;
for (int k=0; k < size; ++k)
{
if (which == k)
break;
temp = temp.getNext();
}
return temp.getData();
} // get
Можете ли вы использовать такие «стандартные java» вещи, как коллекции и алгоритмы, или вы должны делать все сами? – John3136