PriorityQueue Constructor in Java
java, priority-queue, queue
Solution
It's the initial capacity of the `PriorityQueue`. You would generally specify the initial capacity explicitly if you knew before hand how many items you were going to add (or had an approximation).
This can also be seen in the documentation:
`public PriorityQueue(int initialCapacity, Comparator<? super E> comparator)`
Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.
Parameters: - `initialCapacity` - the initial capacity for this priority queue. - `comparator` - the comparator used to order this priority queue. If null then the order depends on the elements' natural ordering.
Throws: - `IllegalArgumentException` - if `initialCapacity` is less than 1
In fact, most collections in Java have constructors that take an int argument specifying the initial capacity.
Problem
Given the example code: ``` Comparator<Node> comparator = this.createCompartor(algorithmChoice , matrix); this.m_openList1 = new PriorityQueue<Node>(100, comparator); ``` What does the `100` in the `PriorityQueue` constructor stand for?