Skip to content

Commit 4944b89

Browse files
committed
Release 1.2.0; Closes #10
1 parent c55afbf commit 4944b89

File tree

8 files changed

+51
-38
lines changed

8 files changed

+51
-38
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
3.0
1+
4.0
22

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 1.2.0
2+
> Note: 1.2.0 is the first version of SwiftPriorityQueue to break compatibility with previous versions of Swift since release 1.0.1. From this point forward users of Swift 2 and Swift 3 should use release 1.1.2 of SwiftPriorityQueue.
3+
4+
- Swift 4 support
5+
- Removed preprocessor macros and code to support Swift 2
6+
17
### 1.1.2
28
- Initializer that takes custom order function added
39
- watchOS added to podspec
@@ -10,8 +16,7 @@
1016
- Swift 3 support
1117

1218
### 1.0.3
13-
- Beginning of work to support Swift 3
14-
- Last release to support Swift 2
19+
- Last Swift 2 only release
1520
- Improved unit tests
1621

1722
### 1.0.2

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# SwiftPriorityQueue
22

3-
SwiftPriorityQueue is a pure Swift (no Cocoa) implementation of a generic priority queue data structure, appropriate for use on all platforms (OS X, iOS, Linux, etc.) where Swift is supported. It features a straightforward interface and can be used with any type that implements `Comparable`. It utilizes comparisons between elements rather than separate numeric priorities to determine order.
3+
SwiftPriorityQueue is a pure Swift (no Cocoa) implementation of a generic priority queue data structure, appropriate for use on all platforms (macOS, iOS, Linux, etc.) where Swift is supported. It features a straightforward interface and can be used with any type that implements `Comparable`. It utilizes comparisons between elements rather than separate numeric priorities to determine order.
44

5-
Internally, SwiftPriorityQueue uses a classic binary heap, resulting in O(lg n) pushes and pops. It includes in-source documentation, an A* based example maze solving program (for OS X), and unit tests (*pull requests are welcome for additional unit tests in particular*).
5+
Internally, SwiftPriorityQueue uses a classic binary heap, resulting in O(lg n) pushes and pops. It includes in-source documentation, an A* based example maze solving program (for macOS), and unit tests (*pull requests are welcome for additional unit tests in particular*).
66

77
## Features
88
* Easy-to-use method interface
@@ -14,7 +14,7 @@ Internally, SwiftPriorityQueue uses a classic binary heap, resulting in O(lg n)
1414

1515
## Installation
1616

17-
Release 1.1.0 and beyond supports Swift 3 (and should still work with Swift 2). Releases 1.0.1 through 1.0.3 support Swift 2. Use release 1.0 for Swift 1.2 support.
17+
Release 1.2.0 and above supports Swift 4. Use release 1.1.2 for Swift 3 and Swift 2 support. Use release 1.0 for Swift 1.2 support.
1818

1919
### CocoaPods
2020

@@ -29,7 +29,7 @@ Add this repository as a dependency.
2929
Copy `SwiftPriorityQueue.swift` into your project.
3030

3131
## Documentation
32-
There is a large amount of documentation in the source code using the standard Swift documentation technique (compatible with Jazzy). Essentially though, SwiftPriorityQueue has the three critical methods you'd expect - push(), pop(), and peek().
32+
There is a large amount of documentation in the source code using the standard Swift documentation technique (compatible with Jazzy). Essentially though, SwiftPriorityQueue has the three critical methods you'd expect - `push()`, `pop()`, and `peek()`.
3333

3434
### Initialization
3535
When you create a new `PriorityQueue` you can optionally specify whether the priority queue is ascending or descending. What does this mean? If the priority queue is ascending, its smallest values (as determined by their implementation of `Comparable` aka `<`) will be popped first, and if it's descending, its largest values will be popped first.

Sources/SwiftPriorityQueue.swift

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SwiftPriorityQueue.swift
33
// SwiftPriorityQueue
44
//
5-
// Copyright (c) 2015 David Kopec
5+
// Copyright (c) 2015-2017 David Kopec
66
//
77
// Permission is hereby granted, free of charge, to any person obtaining a copy
88
// of this software and associated documentation files (the "Software"), to deal
@@ -24,12 +24,6 @@
2424

2525
// This code was inspired by Section 2.4 of Algorithms by Sedgewick & Wayne, 4th Edition
2626

27-
#if !swift(>=3.0)
28-
typealias IteratorProtocol = GeneratorType
29-
typealias Sequence = SequenceType
30-
typealias Collection = CollectionType
31-
#endif
32-
3327
/// A PriorityQueue takes objects to be pushed of any type that implements Comparable.
3428
/// It will pop the objects in the order that they would be sorted. A pop() or a push()
3529
/// can be accomplished in O(lg n) time. It can be specified whether the objects should
@@ -83,7 +77,7 @@ public struct PriorityQueue<T: Comparable> {
8377
if heap.isEmpty { return nil }
8478
if heap.count == 1 { return heap.removeFirst() } // added for Swift 2 compatibility
8579
// so as not to call swap() with two instances of the same location
86-
swap(&heap[0], &heap[heap.count - 1])
80+
heap.swapAt(0, heap.count - 1)
8781
let temp = heap.removeLast()
8882
sink(0)
8983

@@ -97,7 +91,7 @@ public struct PriorityQueue<T: Comparable> {
9791
/// - parameter item: The item to remove the first occurrence of.
9892
public mutating func remove(_ item: T) {
9993
if let index = heap.index(of: item) {
100-
swap(&heap[index], &heap[heap.count - 1])
94+
heap.swapAt(index, heap.count - 1)
10195
heap.removeLast()
10296
swim(index)
10397
sink(index)
@@ -126,11 +120,7 @@ public struct PriorityQueue<T: Comparable> {
126120

127121
/// Eliminate all of the elements from the Priority Queue.
128122
public mutating func clear() {
129-
#if swift(>=3.0)
130-
heap.removeAll(keepingCapacity: false)
131-
#else
132-
heap.removeAll(keepCapacity: false)
133-
#endif
123+
heap.removeAll(keepingCapacity: false)
134124
}
135125

136126
// Based on example from Sedgewick p 316
@@ -143,7 +133,7 @@ public struct PriorityQueue<T: Comparable> {
143133
if j < (heap.count - 1) && ordered(heap[j], heap[j + 1]) { j += 1 }
144134
if !ordered(heap[index], heap[j]) { break }
145135

146-
swap(&heap[index], &heap[j])
136+
heap.swapAt(index, j)
147137
index = j
148138
}
149139
}
@@ -152,7 +142,7 @@ public struct PriorityQueue<T: Comparable> {
152142
private mutating func swim(_ index: Int) {
153143
var index = index
154144
while index > 0 && ordered(heap[(index - 1) / 2], heap[index]) {
155-
swap(&heap[(index - 1) / 2], &heap[index])
145+
heap.swapAt((index - 1) / 2, index)
156146
index = (index - 1) / 2
157147
}
158148
}
@@ -182,11 +172,9 @@ extension PriorityQueue: Collection {
182172

183173
public subscript(i: Int) -> T { return heap[i] }
184174

185-
#if swift(>=3.0)
186-
public func index(after i: PriorityQueue.Index) -> PriorityQueue.Index {
187-
return heap.index(after: i)
188-
}
189-
#endif
175+
public func index(after i: PriorityQueue.Index) -> PriorityQueue.Index {
176+
return heap.index(after: i)
177+
}
190178
}
191179

192180
// MARK: - CustomStringConvertible, CustomDebugStringConvertible

SwiftPriorityQueue.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SwiftPriorityQueue'
3-
s.version = '1.1.2'
3+
s.version = '1.2.0'
44
s.license = 'MIT'
55
s.summary = 'A Generic Priority Queue in Pure Swift'
66
s.homepage = 'https://github.com/davecom/SwiftPriorityQueue'

SwiftPriorityQueue.xcodeproj/project.pbxproj

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@
159159
attributes = {
160160
LastSwiftMigration = 0710;
161161
LastSwiftUpdateCheck = 0710;
162-
LastUpgradeCheck = 0800;
162+
LastUpgradeCheck = 0900;
163163
ORGANIZATIONNAME = "Oak Snow Consulting";
164164
TargetAttributes = {
165165
5539481E1AC6495600666559 = {
166166
CreatedOnToolsVersion = 6.2;
167-
LastSwiftMigration = 0800;
167+
LastSwiftMigration = 0900;
168168
};
169169
5539482E1AC6495600666559 = {
170170
CreatedOnToolsVersion = 6.2;
171-
LastSwiftMigration = 0800;
171+
LastSwiftMigration = 0900;
172172
TestTargetID = 5539481E1AC6495600666559;
173173
};
174174
};
@@ -261,13 +261,21 @@
261261
CLANG_CXX_LIBRARY = "libc++";
262262
CLANG_ENABLE_MODULES = YES;
263263
CLANG_ENABLE_OBJC_ARC = YES;
264+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
264265
CLANG_WARN_BOOL_CONVERSION = YES;
266+
CLANG_WARN_COMMA = YES;
265267
CLANG_WARN_CONSTANT_CONVERSION = YES;
266268
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
267269
CLANG_WARN_EMPTY_BODY = YES;
268270
CLANG_WARN_ENUM_CONVERSION = YES;
271+
CLANG_WARN_INFINITE_RECURSION = YES;
269272
CLANG_WARN_INT_CONVERSION = YES;
273+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
274+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
270275
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
276+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
277+
CLANG_WARN_STRICT_PROTOTYPES = YES;
278+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
271279
CLANG_WARN_UNREACHABLE_CODE = YES;
272280
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
273281
CODE_SIGN_IDENTITY = "-";
@@ -305,13 +313,21 @@
305313
CLANG_CXX_LIBRARY = "libc++";
306314
CLANG_ENABLE_MODULES = YES;
307315
CLANG_ENABLE_OBJC_ARC = YES;
316+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
308317
CLANG_WARN_BOOL_CONVERSION = YES;
318+
CLANG_WARN_COMMA = YES;
309319
CLANG_WARN_CONSTANT_CONVERSION = YES;
310320
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
311321
CLANG_WARN_EMPTY_BODY = YES;
312322
CLANG_WARN_ENUM_CONVERSION = YES;
323+
CLANG_WARN_INFINITE_RECURSION = YES;
313324
CLANG_WARN_INT_CONVERSION = YES;
325+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
326+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
314327
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
328+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
329+
CLANG_WARN_STRICT_PROTOTYPES = YES;
330+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
315331
CLANG_WARN_UNREACHABLE_CODE = YES;
316332
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
317333
CODE_SIGN_IDENTITY = "-";
@@ -342,7 +358,8 @@
342358
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
343359
PRODUCT_BUNDLE_IDENTIFIER = "com.oaksnow.$(PRODUCT_NAME:rfc1034identifier)";
344360
PRODUCT_NAME = "$(TARGET_NAME)";
345-
SWIFT_VERSION = 3.0;
361+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
362+
SWIFT_VERSION = 4.0;
346363
};
347364
name = Debug;
348365
};
@@ -356,7 +373,8 @@
356373
PRODUCT_BUNDLE_IDENTIFIER = "com.oaksnow.$(PRODUCT_NAME:rfc1034identifier)";
357374
PRODUCT_NAME = "$(TARGET_NAME)";
358375
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
359-
SWIFT_VERSION = 3.0;
376+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
377+
SWIFT_VERSION = 4.0;
360378
};
361379
name = Release;
362380
};
@@ -377,7 +395,8 @@
377395
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
378396
PRODUCT_BUNDLE_IDENTIFIER = "com.oaksnow.$(PRODUCT_NAME:rfc1034identifier)";
379397
PRODUCT_NAME = "$(TARGET_NAME)";
380-
SWIFT_VERSION = 3.0;
398+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
399+
SWIFT_VERSION = 4.0;
381400
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftPriorityQueue.app/Contents/MacOS/SwiftPriorityQueue";
382401
};
383402
name = Debug;
@@ -396,7 +415,8 @@
396415
PRODUCT_BUNDLE_IDENTIFIER = "com.oaksnow.$(PRODUCT_NAME:rfc1034identifier)";
397416
PRODUCT_NAME = "$(TARGET_NAME)";
398417
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
399-
SWIFT_VERSION = 3.0;
418+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
419+
SWIFT_VERSION = 4.0;
400420
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftPriorityQueue.app/Contents/MacOS/SwiftPriorityQueue";
401421
};
402422
name = Release;

SwiftPriorityQueue/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// AppDelegate.swift
33
// SwiftPriorityQueue
44
//
5-
// Copyright (c) 2015 David Kopec
5+
// Copyright (c) 2015-2017 David Kopec
66
//
77
// Permission is hereby granted, free of charge, to any person obtaining a copy
88
// of this software and associated documentation files (the "Software"), to deal

SwiftPriorityQueue/astar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// astar.swift
33
// SwiftPriorityQueue
44
//
5-
// Copyright (c) 2015 David Kopec
5+
// Copyright (c) 2015-2017 David Kopec
66
//
77
// Permission is hereby granted, free of charge, to any person obtaining a copy
88
// of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy