Fix label printing order by jacobmanning · Pull Request #2 · googlecodelabs/androidthings-imageclassifier · GitHub
Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Fix label printing order#2

Open
jacobmanning wants to merge 1 commit into
googlecodelabs:masterfrom
jacobmanning:master
Open

Fix label printing order#2
jacobmanning wants to merge 1 commit into
googlecodelabs:masterfrom
jacobmanning:master

Conversation

@jacobmanning

Copy link
Copy Markdown

There is a bug here causing predicted labels to be printed in incorrect order. Traversing a java.util.PriorityQueue with a range-based for loop does not guarantee traversal in sorted order. Fixed by converting PQ to array, sorting array with PQ.comparator(), and returning the results in sorted order.

More information on the undefined behavior of traversing PQ here.

There is a bug here causing predicted labels to be printed in arbitrary order.
Traversing a java.util.PriorityQueue with a range-based for loop does not
guarantee traversal in sorted order. Fixed by converting PQ to array, sorting
array with PQ.comparator(), and returning the results in sorted order.
@googlebot

Copy link
Copy Markdown

@jacobmanning

Copy link
Copy Markdown
Author

@googlebot I signed it!

@googlebot

Copy link
Copy Markdown

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants