Oracle has added remove(Object o). Although I suspect this remove() operation, would be too slow a search.
We need to avoid doing an unnecessary full sort, not everything that is queued will be executed. A binary heap is a standard data structure for a production rule system, to ensure you fire the most prioritised rule, without wasting cpu on a full. Many rules will be cancelled before they fire, due to underlying changes in data.
Ages ago we wrote this, where the interface of the queued item supports fast removal:
See line 316 setElement, which is called during perculateUp and perculateDown, by recording the index we are able to do a fast removal by dequeuing a specific index, see line 186.
Would you be interested in a PR, that adds an optional similar interface and fast removal behaviour to your array based heap queues? We are trying to remove all of our custom collections. The cost would be a single boolean statement, configured at constructor time, as well as the addition of the optional interface that must be implemented by the enqueued/dequeued item?
Regards
Mark