Untitled LL
Untitled LL
Node p = head;
while(pos-- > 1){
if (p.next == null){
System.out.println("position invalid");
return;
}
p = p.next;
}
Node node = new Node(x.info,p.next);
p.next = node;
void RemovePos(int pos){
if (pos == 1){
head = head.next;
return;
}
Node p = head;
while(pos-- > 2){
if (p.next == null){
System.out.println("position invalid");//dont need
return;
}
p = p.next;
}
p.next = p.next.next;
void RemoveLast(){
Node p = head;
while(p.next != tail){
p = p.next;
}
p.next = null;
link list
void Sort(int pos,int quantity){
Node p=head ;
while(pos-- >1){
p=p.next;
}
while(quantity >1){
Node temp =p;
for (int i=0;i <quantity-1;i++){
temp=temp.next;
if(p.info.type>temp.info.type){
Node a =new Node(p.info,p.next);
p.info =temp.info;
temp.info=a.info;
}
}
p=p.next;
quantity--;
}
}
void sortFull() {
Node i =head ;
Node j=null ;
Watermelon tmp ;
while(j !=null){
j=i.next ;
while (j!=null){
if (i.info.price > j.info.price){
tmp =i.info;
i.info=j.info ;
j.info=tmp ;
}
j=j.next;
}
i=i.next;
}
}