Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING: LinkedHash(Map/Set) -> Ordered(Map/Set)
This can be fixed in your code, probably, by doing a search/replace for "LinkedHash" and replacing with "Ordered", then importing `squidpony.squidmath.OrderedMap`, `squidpony.squidmath.OrderedSet`, or `squidpony.squidmath.*`, and removing any appearances of `java.util.OrderedMap` or `java.util.OrderedSet` that mistakenly appeared as a result of the replace. You may also need to change calls to `Maker.makeLHM()` to `Maker.makeOM()`, but both methods are available. There aren't many places where a LinkedHashMap was returned as a specific return type of a SquidLib method, but Placement, RegionMap, ModularMapGenerator, MonsterGen, some of CoordPacker, and virtually all of the AOE-related classes (including AreaUtils, Technique, and the related parts of DijkstraMap) now return `OrderedMap`s instead of `LinkedHashMap`s. SoundMap mistakenly returned `HashMap`s when the ordering did matter, so it now returns `OrderedMap`s. This isn't a strictly necessary change to make in the library, but the memory consumption of OrderedSet is better than LinkedHashSet (because it doesn't store wasteful references to unused values in an internal LinkedHashMap), and both Ordered collections allow better random-access-in-some-order traversal of their data. We also gain the ability to change the ordering, possibly in constant time, and the shuffle() method on both collections does this already (though shuffling takes more time on larger collections, and so is not constant-time). An early case where a "better way" is made possible by these data structures is the removal of `convertThreats()` in the display module's CoveredPathDemo, where it was creating a LinkedHashMap with sequential Integer keys to correspond to the already-unique Threat values in a List. This is represented better with an OrderedSet since the sequential ints associated with Threat values are already present in an OrderedSet for indexing; this is also not possible with a LinkedHashSet. OrderedMap and OrderedSet are likely to get continued improvements over time. If this commit breaks more than it should, please post an issue on GitHub.
- Loading branch information
1 parent
ff209d1
commit 22c770b
Showing
51 changed files
with
913 additions
and
939 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
837 changes: 418 additions & 419 deletions
837
squidlib-performance/src/main/java/squidpony/performance/alternate/DijkstraMap.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.