add copy
This commit is contained in:
parent
3351bce3ef
commit
b1e26cc5da
35
src/StruttureDati/SimpleList/ListNI.java
Normal file
35
src/StruttureDati/SimpleList/ListNI.java
Normal file
@ -0,0 +1,35 @@
|
||||
public class ListNI extends SimpleList{
|
||||
|
||||
public ListNI(){
|
||||
super();
|
||||
}
|
||||
|
||||
public void addAt(int pos, Object elem){
|
||||
if(pos==0)
|
||||
addHead(elem);
|
||||
else if(!isEmpty()){
|
||||
Object headElem=head();
|
||||
remHead();
|
||||
addAt(pos-1, elem);
|
||||
addHead(headElem);
|
||||
}
|
||||
}
|
||||
|
||||
public void remAt(int pos, Object elem){
|
||||
if(pos==0)
|
||||
remHead();
|
||||
else if(!isEmpty()){
|
||||
Object headElem=head();
|
||||
remHead();
|
||||
remAt(pos-1, elem);
|
||||
addHead(headElem);
|
||||
}
|
||||
}
|
||||
|
||||
public ListNI copy(){
|
||||
ListNI list = new ListNI();
|
||||
list.node=this.node;
|
||||
list.len=this.len;
|
||||
return list;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user