From b1e26cc5da00a13ec420eaf23314b9276832d04e Mon Sep 17 00:00:00 2001 From: orange Date: Tue, 27 Dec 2016 18:02:06 +0100 Subject: [PATCH] add copy --- src/StruttureDati/SimpleList/ListNI.java | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/StruttureDati/SimpleList/ListNI.java diff --git a/src/StruttureDati/SimpleList/ListNI.java b/src/StruttureDati/SimpleList/ListNI.java new file mode 100644 index 0000000..66ae221 --- /dev/null +++ b/src/StruttureDati/SimpleList/ListNI.java @@ -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; + } +} \ No newline at end of file