Three things which seem questionable to me (I don't do much Java so I'm not entirely familiar with all the language features):
You access the
private final priorityQueue
which is the backing data structure directly withinSong
(songsQueue.priorityQueue.poll()
)The only public read access to your queue is a method labelled "Do not use"
You have a method in your queue as part of your public interface which is commented as "Do not use". Either remove it, or simply state the draw backs so the user can make it's own decision.
Update
One more thing:
solveUsingFixedPriorityQueue()
contains too much responsibility: it reads the data, solves the problem and outputs the data. Those concerns should be separated:
- Have one method reading the input and building the list of songs
- Pass the list of song to the
solve
method which should return the resulting list/array - Have another write method generating the output by being passed in a list of songs.