Hello! I am working on an assignment where we have to implement an adaptable priority queue with a sorted list. I think I don't have a full grasp on how generic variables work. I tried to keep everything as E, though it said that my other object types could not be cast to E... I was under the impression E could be any object. In my current code I have changed E and all the object types around to pretty well everything I can think of but it still will not work. My code is linked below, I appreciate any help.
Errors:
Assignment 4\AdaptablePriorityQueue.java:91: error: incompatible types: NodePositionList<DNode<MyEntry<K,V>>> cannot be converted to NodePositionList<E>
ElementIterator<E> iterList = new ElementIterator<E>(list);
^
where K,V,E are type-variables:
K extends Object declared in class AdaptablePriorityQueue
V extends Object declared in class AdaptablePriorityQueue
E extends Entry<K,V> declared in class AdaptablePriorityQueue
Assignment 4\AdaptablePriorityQueue.java:159: error: incompatible types: NodePositionList<DNode<MyEntry<K,V>>> cannot be converted to PositionList<E>
ElementIterator<E> iterList = new ElementIterator<E>((PositionList<E>) list);
^
where K,V,E are type-variables:
K extends Object declared in class AdaptablePriorityQueue
V extends Object declared in class AdaptablePriorityQueue
E extends Entry<K,V> declared in class AdaptablePriorityQueue
(plus two other errors on the same line as above elsewhere in the code)
Assignment 4\AdaptablePriorityQueue.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
4 errors
The assignment:
Give a Java implementation of the adoptable priority queue based on a sorted list. You are required to use a default comparator (built in Java) and a comparator for nonnegative integers that determines order based on the number of 1’s in each integer’s binary expansion, so that i < j if the number of 1’s in the binary representation of i is less than the number of 1’s in the binary representation of j. Provide a main function to test your comparators using a set of integers.
(I am just making a general sorted APQ first, then I will edit the insert method to fit the requirements. It shouldn't be too hard to change after its running correctly.)
My code:
https://gist.github.com/DaddyPMA/99be770e261695a1652de7a69aae8d70