fix: remove items from index implementations grid and tree (regression) #357
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
VehicleObject
items in theGrid
orQuadTree
, they were stored as a key within a HashMap. When doing so, the hashCode of the object is used to store it in the map. However, when updating the object (e.g. adjusting its speed value), the object cannot be found anymore since its hashCode has changed and differs from the one stored in the map. This resulted in odd behavior andVehicleObject
s could not be removed from theGrid
orQuadTree
and were therefore returned by the perception module,Grid
andQuadTree
do not store theVehicleObject
items as a key for HashMaps, but only their hash value. This hash value is furthermore generated by theSpatialItemAdapter
. The adapter implementation responsible for theVehicleObject
now returns only the hashcode of its id which is immutable. This refactoring required in theGrid
implementation a new wrapper classItemKey
to be used as a key for the internal HashMap, since direct access to the stored item was required.Issue(s) related to this PR
Affected parts of the online documentation
Changes in the documentation required?
Definition of Done
Prerequisites
Required
type(scope): description
(in the style of Conventional Commits)enhancement
, orbugfix
)origin/main
has been merged into your Fork.Requested (can be enforced by maintainers)
Special notes to reviewer