From de78214a1f7ad79dc2a839ec029ee49eaac41d17 Mon Sep 17 00:00:00 2001 From: Chloe Christine Fontenot Date: Sun, 19 Oct 2025 21:31:19 -0500 Subject: [PATCH] update --- .../Printed HTMLs/CircularList.html | 238 ++++++ .../caleb/mp6_calebfontenot/CircularList.java | 85 +- .../mp6_calebfontenot/PriorityQueueASDV.java | 799 ++++++++++++++++++ Semester 3/ZIPs/MP6_CalebFontenot.zip | Bin 0 -> 8179 bytes 4 files changed, 1114 insertions(+), 8 deletions(-) create mode 100644 Semester 3/Assignments/MP6_CalebFontenot/Printed HTMLs/CircularList.html create mode 100644 Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/PriorityQueueASDV.java create mode 100644 Semester 3/ZIPs/MP6_CalebFontenot.zip diff --git a/Semester 3/Assignments/MP6_CalebFontenot/Printed HTMLs/CircularList.html b/Semester 3/Assignments/MP6_CalebFontenot/Printed HTMLs/CircularList.html new file mode 100644 index 0000000..c2855c3 --- /dev/null +++ b/Semester 3/Assignments/MP6_CalebFontenot/Printed HTMLs/CircularList.html @@ -0,0 +1,238 @@ + + + +CircularList.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/CircularList.java
+
+package edu.slcc.asdv.caleb.mp6_calebfontenot;
+
+/**
+ *
+ * @author Markou
+ */
+public class CircularList<T extends Comparable<T>> {
+
+    Node<T> head;
+
+    public class Node< T extends Comparable<T>>
+            implements Comparable<Node<T>> {
+
+        private T t;
+
+        public void set(T t)
+        {
+            this.t = t;
+        }
+
+        public T get()
+        {
+            return t;
+        }
+        Node<T> next;
+
+        @Override
+        public int compareTo(Node<T> o)
+        {
+            return this.t.compareTo(o.get());
+        }
+    }
+
+    /**
+     *
+     * @param t
+     */
+    public void add(Object t)
+    {
+        Node<T> temp = new Node();
+        temp.set((T) t);
+
+        if (head == null) {
+            head = temp;
+            head.next = head;
+        } else {
+            Node<T> temp2 = head;
+            do {
+                temp2 = temp2.next;
+            } while (temp2.next != head);
+            temp.next = head;
+            temp2.next = temp;
+        }
+    }
+
+    /**
+     *
+     * @return
+     */
+    private int getSize()
+    {
+        if (head == null) {
+            return 0;
+        }
+        Node<T> temp = head;
+        int count = 0;
+        do {
+            temp = temp.next;
+            count++;
+        } while (temp != head);
+
+        return count;
+    }
+    ////////////////////////////////////////////////////////
+
+    public void addAt(Object t, int pos)
+    {
+        if (pos < 0 || pos > getSize()) {
+            return;
+        }
+
+        Node<T> temp = new Node();
+        temp.set((T) t);
+
+        if (head == null) {
+            add(t);
+        } else if (pos == 0) {
+            int oldSize = getSize();
+            Node<T> currentHead = head;
+            temp.next = head;
+            head = temp;
+            // Set the node at the end of the list to point back to the new head.
+            Node<T> pointer = head;
+            for (int i = 0; i < oldSize; ++i) {
+                pointer = pointer.next;
+            }
+            pointer.next = temp;
+        } else {
+            // Iterate to the desired position
+            Node<T> pointer = head;
+            for (int i = 0; i < pos -1; ++i) {
+                pointer = pointer.next;
+            }
+            temp.next = pointer.next;
+            pointer.next = temp;
+        }
+    }
+//////////////////////////////////////////////////////////////
+/**
+ * removes the last node
+ */
+    public void remove()
+    {
+        Node<T> pointer = head;
+        for (int i = 0; i < this.getSize() - 2; ++i) {
+             pointer = pointer.next;
+        }
+        pointer.next = head;
+    }
+//////////////////////////////////////////////////////////////
+/**
+ * removes a specific object from the list
+ */
+    public boolean remove(Object t)
+    {
+        Node<T> pointer = head;
+        boolean isObjectRemoved = false;
+        do {
+            boolean eval = pointer.next.t.equals(t);
+            if (eval) {
+                isObjectRemoved = true;
+                pointer.next = pointer.next.next;
+                break;
+            } else {
+                pointer = pointer.next;
+            }
+        } while (pointer != head);
+        return isObjectRemoved;
+    }
+//////////////////////////////////////////////////////////////
+
+    public void removeAt(int pos)
+    {
+        Node<T> pointer = head;
+        for (int i = 0; i < pos; ++i) {
+            boolean eval = i == pos - 1;
+            if (eval) {
+                pointer.next = pointer.next.next;
+                break;
+            } else {
+                pointer = pointer.next;
+            }
+        }
+    }
+
+    public void print()
+    {
+
+        if (head == null) {
+            return;
+        }
+        Node<T> temp = head;
+        int elementNum = 0;
+        do {
+            System.out.print(++elementNum + ": ");
+            System.out.println(temp.get().toString());
+            temp = temp.next;
+        } while (temp != head);
+
+    }
+
+    public static void main(String... ar)
+    {
+        CircularList<String> list = new CircularList();
+        list.add("Hello");
+        list.add("World");
+        list.add("one");
+        String removeMe = "two";
+        list.add(removeMe);
+        list.add("three");
+        list.add("four");
+        list.add("five");
+        list.add("six");
+        list.add("seven");
+        list.print();
+        System.out.println("-------------");
+        System.out.println("Remove the last object:");
+        list.remove();
+        list.print();
+        System.out.println("-------------");
+        System.out.println("Remove \"two\"");
+        list.remove(removeMe);
+        list.print();
+        System.out.println("-------------");
+        System.out.println("Remove the 3rd element:");
+        list.removeAt(2);
+        list.print();
+        System.out.println("-------------");
+        System.out.println("Add an element to the beginning");
+        list.addAt("Earth", 0);
+        list.print();
+        System.out.println("-------------");
+        System.out.println("Add an element named \"potato\" in the 4th position:");
+        list.addAt("potato", 3);
+        list.print();
+    }
+
+}
+
+
+ diff --git a/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/CircularList.java b/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/CircularList.java index c7f858d..bc64b3a 100644 --- a/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/CircularList.java +++ b/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/CircularList.java @@ -85,18 +85,37 @@ public class CircularList> { if (head == null) { add(t); } else if (pos == 0) { - + int oldSize = getSize(); + Node currentHead = head; + temp.next = head; + head = temp; + // Set the node at the end of the list to point back to the new head. + Node pointer = head; + for (int i = 0; i < oldSize; ++i) { + pointer = pointer.next; + } + pointer.next = temp; } else { - + // Iterate to the desired position + Node pointer = head; + for (int i = 0; i < pos -1; ++i) { + pointer = pointer.next; + } + temp.next = pointer.next; + pointer.next = temp; } } ////////////////////////////////////////////////////////////// /** - * removes the + * removes the last node */ public void remove() { - + Node pointer = head; + for (int i = 0; i < this.getSize() - 2; ++i) { + pointer = pointer.next; + } + pointer.next = head; } ////////////////////////////////////////////////////////////// /** @@ -104,13 +123,34 @@ public class CircularList> { */ public boolean remove(Object t) { - return true; + Node pointer = head; + boolean isObjectRemoved = false; + do { + boolean eval = pointer.next.t.equals(t); + if (eval) { + isObjectRemoved = true; + pointer.next = pointer.next.next; + break; + } else { + pointer = pointer.next; + } + } while (pointer != head); + return isObjectRemoved; } ////////////////////////////////////////////////////////////// public void removeAt(int pos) { - + Node pointer = head; + for (int i = 0; i < pos; ++i) { + boolean eval = i == pos - 1; + if (eval) { + pointer.next = pointer.next.next; + break; + } else { + pointer = pointer.next; + } + } } public void print() @@ -120,7 +160,9 @@ public class CircularList> { return; } Node temp = head; + int elementNum = 0; do { + System.out.print(++elementNum + ": "); System.out.println(temp.get().toString()); temp = temp.next; } while (temp != head); @@ -129,11 +171,38 @@ public class CircularList> { public static void main(String... ar) { - CircularList list = new CircularList(); + CircularList list = new CircularList(); list.add("Hello"); list.add("World"); + list.add("one"); + String removeMe = "two"; + list.add(removeMe); + list.add("three"); + list.add("four"); + list.add("five"); + list.add("six"); + list.add("seven"); + list.print(); + System.out.println("-------------"); + System.out.println("Remove the last object:"); + list.remove(); + list.print(); + System.out.println("-------------"); + System.out.println("Remove \"two\""); + list.remove(removeMe); + list.print(); + System.out.println("-------------"); + System.out.println("Remove the 3rd element:"); + list.removeAt(2); + list.print(); + System.out.println("-------------"); + System.out.println("Add an element to the beginning"); + list.addAt("Earth", 0); + list.print(); + System.out.println("-------------"); + System.out.println("Add an element named \"potato\" in the 4th position:"); + list.addAt("potato", 3); list.print(); - } } diff --git a/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/PriorityQueueASDV.java b/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/PriorityQueueASDV.java new file mode 100644 index 0000000..cf74ce0 --- /dev/null +++ b/Semester 3/Assignments/MP6_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp6_calebfontenot/PriorityQueueASDV.java @@ -0,0 +1,799 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.caleb.mp6_calebfontenot; + +/** + * + * @author caleb + */ +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.PriorityQueue; +import java.util.Queue; +import java.util.function.Consumer; + +public class PriorityQueueASDV> + implements Queue, Cloneable +{ + + private Node head;//head + private Node tail;//tail + + class Node + { + + E e; + Node l; + Node r; + } + + /** + * Inserts the specified element into this queue if it is possible to do so + * immediately without violating capacity restrictions, returning true upon + * success and throwing an IllegalStateException if no space is currently + * available. + * + * Specified by: add in interface Collection + * Parameters: e - the element to add Returns: true (as specified by + * Collection.add(E)) Throws: IllegalStateException - if the element cannot + * be added at this time due to capacity restrictions ClassCastException - + * if the class of the specified element prevents it from being added to + * this queue NullPointerException - if the specified element is null and + * this queue does not permit null elements IllegalArgumentException - if + * some property of this element prevents it from being added to this queue + * + * @param e - the element to add + * @return true if this collection changed as a result of the call + * @throws IllegalStateException - if the element cannot be added at this + * time due to capacity restrictions + * @throws ClassCastException - if the class of the specified element + * @throws NullPointerException - if the specified element is null and this + * queue does not permit null elements + * @throws IllegalArgumentException - if some property of this element + * prevents it from being added to this queue + */ + @Override + public boolean add(E e) + { + if (e == null) + { + throw new NullPointerException("NULL elements not allowed!"); + } + + Node newNode = new Node(); + newNode.e = e; + + //1. empty queue + if (this.head == null && this.tail == null) + { + this.head = this.tail = newNode; + return true; + } + + int index = findCorrectPositionToInsertElement(e); + //int index = findCorrectPositionToInsertElementHashCode(e); + + //2. we add at size ( last node) + if (index == size()) + { + tail.r = newNode;//1 + newNode.l = tail;//2 + tail = newNode;//3 + } + //3. we add at 0 in the front + else if (index == 0) + { + newNode.r = head; + this.head.l = newNode; + this.head = newNode; + if (size() == 1) + { + tail = head; + } + } + //4. we add in the middle + else + { + Node p = head; + + for (int i = 0; i < index - 1; ++i) + { + p = p.r; + } + + //after for loop p point one position before insertion + newNode.l = p;//we connect the left of the new node + //to the node that is BEFORE + //the node to be inserted + + newNode.r = p.r;//we connect the right of the new node + // to the node thta is AFTER + //the node to be inserted + + p.r = newNode; //we connect the right the node BEFORE the node + //to be inserted to the new node + + p.r.r.l = newNode;//we connect the left of the node AFTER the node + //to be iserted to the new node + } + + return true; + } + + @Override + public int size() + { + Node p = this.head; + int count = 0; + while (p != null) + { + p = p.r; + count++; + } + return count; + } + + private int findCorrectPositionToInsertElement(E e) + { + Node p = this.head; + int pos = 0; + while (p != null) + { + if (e.compareTo(p.e) > 0) + { + p = p.r; + ++pos; + } + else + { + break; + } + } + + return pos; + } + + private int findCorrectPositionToInsertElementHashCode(E e) + { + Node p = this.head; + int pos = 0; + while (p != null) + { + if (e.hashCode() > p.e.hashCode()) + { + p = p.r; + ++pos; + } + else + { + break; + } + } + + return pos; + } + + /** + * Inserts the specified element into this queue if it is possible to do so + * immediately without violating capacity restrictions. When using a + * capacity-restricted queue, this method is generally preferable to add(E), + * which can fail to insert an element only by throwing an exception. + * + * @param e - the element to add + * @throws IllegalStateException - if the element cannot be added at this + * time due to capacity restrictions + * @throws ClassCastException - if the class of the specified element + * @throws NullPointerException - if the specified element is null and this + * queue does not permit null elements + * @throws IllegalArgumentException - if some property of this element + * prevents it from being added to this queue + * @return true if the element was added + */ + @Override + public boolean offer(E e) + { + return add(e); + } + + @Override + public E remove() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + /** + * Retrieves and removes the head of this queue, or returns null if this + * queue is empty. + * + * Returns: the head of this queue, or null if this queue is empty + * + * @return + */ + @Override + public E poll() + { + if (size() == 0) + { + return null; + } + if (size() > 1) + { + head = head.r; + + E e = head.l.e; + head.l = null; + return e; + } + else //size 1 + { + E e = head.e; + head = tail = null; + return e; + } + } + + @Override + public E element() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public E peek() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean isEmpty() + { + return head == null && tail == null ? true : false; + + } + + @Override + public boolean contains(Object o) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Iterator iterator() + { + Iterator it = new Iterator() + { + Node p = head; + + @Override + public boolean hasNext() + { + return p == null ? false : true; + } + + @Override + public E next() + { + if (hasNext() == false) + { + throw new NoSuchElementException("the is no next element"); + } + E e = p.e; + p = p.r; + return e; + } + + @Override + public void forEachRemaining(Consumer action) + { + while (hasNext()) + { + action.accept(p.e); + p = p.r; + } + } + }; + + return it; + + } + + @Override + public Object[] toArray() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public T[] toArray(T[] a) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + /** + * Removes a single instance of the specified element from this collection, + * if it is present (optional operation). More formally, removes an element + * e such that (o==null ? e==null : o.equals(e)), if this collection + * contains one or more such elements. Returns true if this collection + * contained the specified element (or equivalently, if this collection + * changed as a result of the call). + * + * @param o - element to be removed from this collection, if present + * @throws ClassCastException - if the type of the specified element is + * incompatible with this collection + * @throws NullPointerException - if the specified element is null and this + * collection does not permit null elements + * @return true if an element was removed as a result of this call + */ + @Override + public boolean remove(Object o) + { + if (o == null) + { + throw new NullPointerException("null vales not allowed"); + } + if (size() == 0) + { + return false; + } + + Node p = this.head; + int pos = 0; + while (p != this.tail) + { + if (p.e.equals(o)) + { + if (size() == 1) + { + this.head = this.tail = null; + return true; + } + this.removeAt(pos, (E) o); + break; + } + ++pos; + p = p.r; + } + if (p == tail && p.e.equals(o)) + { + this.removeAt(size() - 1, (E) o); + } + return true; + } + + /** + * + * @param pos + * @param e + * @throws IndexOutOfBoundsException - if pos less 0 OR pos greater-equal + * size() + * @return + */ + private boolean removeAt(int pos, E e) + { + if (pos < 0 || pos >= size()) + { + throw new IndexOutOfBoundsException(pos + " is out of bounds"); + } + //1.list is empty + if (isEmpty()) + { + return false; + } + //2. one node exists + else if (size() == 1) + { + this.head = this.tail = null; + } + //3. remove in the front( head) + else if (pos == 0) + { + this.head = this.head.r; + head.l = null; + } + //4. remove in the end ( tail) + else if (pos == size() - 1) + { + this.tail = this.tail.l; + this.tail.r = null; + } + + //5. remove in the middle ( at least 3 nodes are in the queue) + else + { + Node p = head; + for (int i = 0; i < pos - 1; ++i) + { + p = p.r; + } + p.r = p.r.r; + p.r.l = p; + } + return true; + } + + @Override + public boolean containsAll(Collection c) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + /** + * Adds all of the elements in the specified collection to this collection + * (optional operation). The behavior of this operation is undefined if the + * specified collection is modified while the operation is in progress. + * (This implies that the behavior of this call is undefined if the + * specified collection is this collection, and this collection is + * nonempty.) + * + * @param c - collection containing elements to be added to this collection + * @throws ClassCastException - if the class of an element of the specified + * collection prevents it from being added to this collection. + * @throws NullPointerException - if the specified collection contains a + * null element and this collection does not permit null elements, or if the + * specified collection is null + * @throws IllegalArgumentException - if some property of an element of the + * specified collection prevents it from being added to this collection + * @throws IllegalArgumentException - if some property of an element of the + * specified collection prevents it from being added to this collection + * @return true if this collection changed as a result of the call + */ + @Override + public boolean addAll(Collection c) + { + int sizeBefore = size(); + for (E e : c) + { + add(e); + } + int sizeAfter = size(); + return sizeAfter > sizeBefore; + } + + @Override + public boolean removeAll(Collection c) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean retainAll(Collection c) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void clear() + { + // head = tail = null; + + //extra, no necessary to set the link of every node + Node p = head ; + while ( p != tail ) + { + p = p.r; + p.l = null; + } + head = tail = null; + } + + @Override + public void forEach(Consumer action) + { + //1. use a pointer that points to the head + //2. while the pointer has not reached the end of the queue + //consume it + Node p = head; + while ( p != null) + { + action.accept(p.e); + p = p.r; + } + + } + + @Override + public String toString() + { + String s = "PriorityQueueASDV {"; + Node p = head; + while (p != null) + { + s += p.e.toString(); + if (p != tail) + { + s += ", "; + } + p = p.r; + } + + s += "}"; + return s; + } + + @Override + protected Object clone() + throws CloneNotSupportedException + { + PriorityQueueASDV c = ( PriorityQueueASDV ) super.clone(); + return c; + } + + public static void main(String[] args) + { + System.out.println("\n--> PriorityQueueASDV testing add"); + PriorityQueueASDV pq1 = new PriorityQueueASDV(); + pq1.add("Paris"); + pq1.add("Athens"); + pq1.add("London"); + pq1.add("Lafayette"); + pq1.add("Berlin"); + + System.out.println(pq1); + + System.out.println("\n--> Colllections PriorityQueue testing add"); + + PriorityQueue pq2 = new PriorityQueue(); + pq2.add("Paris"); + pq2.add("Athens"); + pq2.add("London"); + pq2.add("Lafayette"); + pq2.add("Berlin"); + + System.out.println(pq2); + + //TEST IT FULLY HERE. FOR ALL METHODS AND ALL CASES. + //Have the Jzva PriorityQueue below + System.out.println("\n--> PriorityQueueASDV testing remove(object o)"); + System.out.println("\n\tremove from front Athens"); + pq1.remove("Athens"); + pq2.remove("Athens"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from end Paris"); + pq1.remove("Paris"); + pq2.remove("Paris"); + System.out.println(pq1); + System.out.println(pq1); + + System.out.println("\n\tremove from the middle Lafayette"); + pq1.remove("Lafayette"); + pq2.remove("Lafayette"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tadd at the end Stocholm"); + pq1.add("Stocholm"); + pq2.add("Stocholm"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from the middle London"); + pq1.remove("London"); + pq2.remove("London"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from the front Berlin"); + pq1.remove("Berlin"); + pq2.remove("Berlin"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from the front/end Stocholm"); + pq1.remove("Stocholm"); + pq2.remove("Stocholm"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from empty queue"); + pq1.remove("Stocholm"); + pq2.remove("Stocholm"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n--> PriorityQueueASDV recreate priority queues from empty"); + pq1.add("Paris"); + pq1.add("Athens"); + pq1.add("London"); + pq1.add("Lafayette"); + pq1.add("Berlin"); + pq1.add("Zurich"); + + pq2.add("Paris"); + pq2.add("Athens"); + pq2.add("London"); + pq2.add("Lafayette"); + pq2.add("Berlin"); + pq2.add("Zurich"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\n+++HERE YOU TEST ALL YOUR METHODS FULLY, and the methods of Colleciion PriorityQueue"); + + System.out.println("\n\t offer New York"); + pq1.offer("New York"); + pq2.offer("New York"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t offer Miami"); + pq1.offer("Miami"); + pq2.offer("Miami"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t offer null"); + try + { + pq1.offer(null); + } + catch (Exception e) + { + System.err.println(e); + } + + try + { + pq2.offer(null); + } + catch (Exception e) + { + System.err.println(e); + } + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t offer ClassCastException with Object"); + try + { + pq1.offer((String) new Object()); + } + catch (Exception e) + { + System.err.println(e); + } + + try + { + pq2.offer((String) new Object()); + } + catch (Exception e) + { + System.err.println(e); + } + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t poll suposed to be Athens"); + System.out.println(pq1.poll()); + System.out.println(pq2.poll()); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t Iterator"); + Iterator it1 = pq1.iterator(); + Iterator it2 = pq2.iterator(); + + while (it1.hasNext()) + { + System.out.print(it1.next() + " "); + } + + System.out.println(""); + + while (it2.hasNext()) + { + System.out.print(it2.next() + " "); + } + System.out.println(""); + + System.out.println("\n\t Iterator NoSuchElementException "); + + try + { + System.out.println(it1.next()); + } + catch (NoSuchElementException e) + { + System.err.println(e); + } + try + { + System.out.println(it2.next()); + } + catch (NoSuchElementException e) + { + System.err.println(e); + } + + System.out.println("\n\t Iterator foreach "); + it1 = pq1.iterator(); + it2 = pq2.iterator(); + it1.forEachRemaining(new Consumer() + { + @Override + public void accept(Object t) + { + System.out.print(t + "*** "); + } + }); + System.out.println(""); + it2.forEachRemaining(new Consumer() + { + @Override + public void accept(Object t) + { + System.out.print(t + "+++ "); + } + }); + System.out.println(""); + + System.out.println("\n\t addAll Houston Chicago"); + List ar1 = Arrays.asList("Houston", "Chicago"); + pq1.addAll(ar1); + pq2.addAll(ar1); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t clear" ); + pq1.clear(); + pq2.clear(); + System.out.println(pq1); + System.out.println(pq2); + System.out.println(""); + + System.out.println("\n--> PriorityQueueASDV recreate priority queues from empty"); + pq1.add("Paris"); + pq1.add("Athens"); + pq1.add("London"); + pq1.add("Lafayette"); + pq1.add("Berlin"); + pq1.add("Zurich"); + + pq2.add("Paris"); + pq2.add("Athens"); + pq2.add("London"); + pq2.add("Lafayette"); + pq2.add("Berlin"); + pq2.add("Zurich"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t forEach"); + pq1.forEach(new Consumer(){ + @Override + public void accept(Object t) + { + System.out.print( t + "*** "); + } + }); + System.out.println(""); + pq2.forEach(new Consumer(){ + @Override + public void accept(Object t) + { + System.out.print( t + "+++ "); + } + }); + System.out.println(""); + + System.out.println("\n\t clone"); + try{PriorityQueueASDV pq1Cloned = + ( PriorityQueueASDV) pq1.clone(); + System.out.println(pq1Cloned); + pq1Cloned.add("Las Vegas"); + System.out.println(pq1Cloned); + System.out.println(pq1); + + } + catch(CloneNotSupportedException e ){System.err.println(e);} + + + } +} diff --git a/Semester 3/ZIPs/MP6_CalebFontenot.zip b/Semester 3/ZIPs/MP6_CalebFontenot.zip new file mode 100644 index 0000000000000000000000000000000000000000..9444342979cc27948102256cbfe98e040b41815f GIT binary patch literal 8179 zcmWIWW@h1HVBlb2NU2K?XFvi%3=9mu0cP>ei8-lBZuxm7sd@P&`Uv%fXzCTPt1rsT zD@jdJ@CfnsDF*8nVc_84U_jSxNQ7?Z%%bGdoWvrZ%;FNgjFQ}(x6!r!w=E?8@1K9@ z^vh*N*H|>BOm{NnGs|7R(RcCgmrEwAnHNU)tGtt0E_?jPyL9XKD=({MHr{oq$WH!U z`QNtg&k`AX%li6j|9>C${;;e5qgc(4FUN12r#oaz9((?6X5yUh=bIa2YqM_~#O=G> zV3w9slp?YDrqBGXrB3c{{}&sk_3h2B=t-LVQf%{&Y zadP>;)z=ymUT(~mX56SSC%tOkj{i%pX7O~C^5*#@30JYyHMcj{ZobUQoDtWn@iBI_ zDDPXIBjMsamdCFNSl!rX$HZ6IY2K)|E7wOOid&YAy{zj}FC+e}du`3^GP&{G!H5464zRa;zZ00nAou3I?5DZ# zs?F8WkGlD19Vy%qA5@joseiK0Tt8$Y*TdSE`;;3bw`|nZeDhRvg-@ck{!Jk+;}-Yi zG8VQY+f*9Mx)|QP+1k1?Cr^OuZORdo@BFu{xA%s1yU$i!DxiPphWJ8t1qE5V!(!6& zGj2ym@6XFqY#RTf2^mk?%`RNHd#fW=;$|Es^Mw|5nG$~^g4c)`ri zwqIYM?R!r*|6Kj_q*vOUf`@qeXSFeJ%;sp3Jn@P5yqPa^)io29S3XwpPgW;xaclKi zeY`&KqqoO7(+3On1I!xr402yosz+sTu08Hs!Rp?jecrvg!T2g`aIC>qRqfio%!ih_=n8YW<3EC$G8N8giaEj8#PWuOm zD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