@@ -13,24 +13,28 @@ import Swift
1313
1414/// A double-ended priority queue built on top of `Heap`.
1515public struct PriorityQueue < Value, Priority: Comparable > {
16- public typealias Element = ( value: Value , priority: Priority )
16+ public typealias Pair = ( value: Value , priority: Priority )
1717
18- public struct Pair : Comparable {
18+ @usableFromInline
19+ struct Element : Comparable {
1920 @usableFromInline let value : Value
2021 let priority : Priority
2122 let insertionCounter : UInt64
2223
23- public init ( value: Value , priority: Priority , insertionCounter: UInt64 ) {
24+ @usableFromInline
25+ init ( value: Value , priority: Priority , insertionCounter: UInt64 ) {
2426 self . value = value
2527 self . priority = priority
2628 self . insertionCounter = insertionCounter
2729 }
2830
29- public static func == ( lhs: Self , rhs: Self ) -> Bool {
31+ @usableFromInline
32+ static func == ( lhs: Self , rhs: Self ) -> Bool {
3033 lhs. priority == rhs. priority
3134 }
3235
33- public static func < ( lhs: Self , rhs: Self ) -> Bool {
36+ @usableFromInline
37+ static func < ( lhs: Self , rhs: Self ) -> Bool {
3438 if lhs. priority < rhs. priority {
3539 return true
3640 } else if lhs. priority == rhs. priority {
@@ -42,7 +46,7 @@ public struct PriorityQueue<Value, Priority: Comparable> {
4246 }
4347
4448 @usableFromInline
45- internal var _base : Heap < Pair >
49+ internal var _base : Heap < Element >
4650
4751 @usableFromInline
4852 internal var _insertionCounter : UInt64 = 0
@@ -78,7 +82,7 @@ public struct PriorityQueue<Value, Priority: Comparable> {
7882 public mutating func insert( _ value: Value , priority: Priority ) {
7983 defer { _insertionCounter += 1 }
8084
81- let pair = Pair (
85+ let pair = Element (
8286 value: value,
8387 priority: priority,
8488 insertionCounter: _insertionCounter
@@ -147,12 +151,12 @@ extension PriorityQueue {
147151 ///
148152 /// - Complexity: O(n), where `n` is the length of `elements`.
149153 @inlinable
150- public init < S: Sequence > ( _ elements: S ) where S. Element == Element {
154+ public init < S: Sequence > ( _ elements: S ) where S. Element == Pair {
151155 _base = Heap (
152156 elements
153157 . enumerated ( )
154158 . map ( {
155- Pair (
159+ Element (
156160 value: $0. element. value,
157161 priority: $0. element. priority,
158162 insertionCounter: UInt64 ( $0. offset)
0 commit comments