diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a818314 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0512aaa --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/multiset-adt.iml b/multiset-adt.iml new file mode 100644 index 0000000..e5d2daf --- /dev/null +++ b/multiset-adt.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ArrayList.java b/src/ArrayList.java new file mode 100644 index 0000000..79c6462 --- /dev/null +++ b/src/ArrayList.java @@ -0,0 +1,2 @@ +package PACKAGE_NAME;public class ArrayList { +} diff --git a/src/LinkedListMultiSet.java b/src/LinkedListMultiSet.java new file mode 100644 index 0000000..23fdbb5 --- /dev/null +++ b/src/LinkedListMultiSet.java @@ -0,0 +1,37 @@ +public class LinkedListMultiSet implements MultiSet { + /** + * Unlike the TreeMultiList, this implementation does not just "wrap" an + * underlying tree, it is instead a custom LinkedList implementation, which + * only provides the necessary MultiSet methods. + * + * Representation Invariant: + * front is null represents an empty MultiSet + */ + + private Node front; + private int size; + + public LinkedListMultiSet() { + front = null; + size = 0; + } + + // You would need to implement the MultiSet interface methods here + // For example: + @Override + public void add(T item) { + // Implement the add method + } + + @Override + public int count(T item) { + // Implement the count method + return 0; + } + + @Override + public void remove(T item) { + // Implement the remove method + } + + diff --git a/src/MultisetADT.java b/src/MultisetADT.java new file mode 100644 index 0000000..9bca5be --- /dev/null +++ b/src/MultisetADT.java @@ -0,0 +1,9 @@ +public interface MultisetADT { + public boolean add(Object item); + public void remove(Object item); + public boolean contains(Object item); + public boolean is_empty(); + public int count(Object item); + public int size(); + +} diff --git a/src/Node.java b/src/Node.java new file mode 100644 index 0000000..ca37396 --- /dev/null +++ b/src/Node.java @@ -0,0 +1,9 @@ +public class Node { + public T item; + public Node next; + + public Node(T item) { + this.item = item; + this.next = null; + } +} \ No newline at end of file diff --git a/src/Tree.java b/src/Tree.java index 458a7c7..12709ef 100644 --- a/src/Tree.java +++ b/src/Tree.java @@ -1,2 +1,48 @@ -public class Tree { -} +import java.util.ArrayList; + +public class Tree implements MultisetADT { + private int root; + private ArrayList subtrees; + + public Tree(int root, ArrayList subtrees) { + this.root = root; + + if (subtrees.isEmpty()) { + this.subtrees = null; + } + else { + this.subtrees = subtrees; + } + } + + + @Override + public boolean add(Object item) { + return false; + } + + @Override + public void remove(Object item) { + + } + + @Override + public boolean contains(Object item) { + return false; + } + + @Override + public boolean is_empty() { + return false; + } + + @Override + public int count(Object item) { + return 0; + } + + @Override + public int size() { + return 0; + } +} \ No newline at end of file