diff --git a/src/StruttureDati/SimpleList/SimpleList.java b/src/StruttureDati/SimpleList/SimpleList.java new file mode 100644 index 0000000..cdc2dde --- /dev/null +++ b/src/StruttureDati/SimpleList/SimpleList.java @@ -0,0 +1,45 @@ +public class SimpleList{ + + private class Node{ + public Object elem; + public Node next; + } + + public SimpleList(){ + node=null; + len=0; + } + + public boolean isEmpty(){ + return node==null; + } + + public int size(){ + return len; + } + + public Object head(){ + if(node==null) + return null; + else + return node.elem; + } + + public void addHead(Object nuovo){ + Node tmp=new Node(); + tmp.elem=nuovo; + tmp.next=node; + node=tmp; + len++; + } + + public void remHead();{ + if(node!=null){ + node=node.next; + len--; + } + } + + private Node node; + private int len; +} \ No newline at end of file