From 7be287ed7f405bbc7dafd2a876ece60619c1acb1 Mon Sep 17 00:00:00 2001 From: orange Date: Tue, 27 Dec 2016 18:08:16 +0100 Subject: [PATCH] Lista senza interferenze --- src/StruttureDati/SimpleList/ListNI.java | 2 +- src/StruttureDati/SimpleList/Test.java | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/StruttureDati/SimpleList/ListNI.java b/src/StruttureDati/SimpleList/ListNI.java index e4e7faa..8033c9f 100644 --- a/src/StruttureDati/SimpleList/ListNI.java +++ b/src/StruttureDati/SimpleList/ListNI.java @@ -21,7 +21,7 @@ public class ListNI extends SimpleList{ else if(!isEmpty()){ Object headElem=head(); remHead(); - remAt(pos-1, elem); + remAt(pos-1); addHead(headElem); } } diff --git a/src/StruttureDati/SimpleList/Test.java b/src/StruttureDati/SimpleList/Test.java index 7f89d91..3f03c34 100644 --- a/src/StruttureDati/SimpleList/Test.java +++ b/src/StruttureDati/SimpleList/Test.java @@ -3,7 +3,8 @@ import java.util.Scanner; public class Test{ public static void main(String [] args) throws Exception { Scanner sc = new Scanner(System.in); - SimpleList list = new SimpleList(); + ListNI list = new ListNI(); + ListNI list2; System.out.println("Stringa: "); String line = sc.nextLine(); @@ -14,12 +15,20 @@ public class Test{ line = sc.nextLine(); } - System.out.println("lunghezza lista: " + list.size()); + list2=list.copy(); + list2.addAt(3, "prova"); + list.remAt(2); while(!list.isEmpty()){ line = (String) list.head(); - System.out.println(line); + System.out.print(line+" --> "); list.remHead(); } + System.out.println(); + while(!list2.isEmpty()){ + line = (String) list2.head(); + System.out.print(line+" --> "); + list2.remHead(); + } } } \ No newline at end of file