Beispiel
show how omitting the queue comparator changes element priority semantics
sha256:4c5ea45d1953eb6c9bee6f0124f6cac8618d0a6fde9ad4c2d477cdea982b3a36
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- show how omitting the queue comparator changes element priority semantics HOW
- Pakete
- collection 1.19.1
- Umgebung
- dart
- Erstellt
- 2026-08-17T02:04:34Z
Häufige Annahme
A priority queue should return the largest value first when no comparator is supplied.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- A `PriorityQueue` without a comparator argument is a min-heap, so `removeFirst()` returns 1 before 3 from [3, 1, 5].
- Removing from a default `PriorityQueue<int>` created with [3, 1, 5] yields 1 first, then 3, then 5.
- Providing `(a, b) => b.compareTo(a)` to `PriorityQueue` flips default priority and returns 5 before 1 for the same values.
Dateien
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-16 · ed25519:d91480838ac982c9