Data Structures and Interfaces
The currentStates member is a list of StateAndDom instances. In addition to its normal liststyle operations (i.e., iteration, removal of an element, testing for membership, addition of an element), it supports two operations specific for this algorithm.
The sortByDecreasingDOM method returns a copy of the list sorted in order of decreasing DOM values. It does not make copies of any of the StateAndDom instances in the list. We need a copy, since we’ll be making changes to the original while we iterate through its contents. This can cause problems or infinite loops (although no infinite loops will be caused in this algorithm), so it is to be avoided as good programming practice.
The get method looks up a StateAndDom ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access