Skip to content

Commit cd02bd0

Browse files
authored
Merge pull request kodecocodes#800 from erikstrottmann/trie-swift-4.2
[Swift 4.2] Update Trie
2 parents e6c9527 + 22efd0d commit cd02bd0

File tree

8 files changed

+317
-307
lines changed

8 files changed

+317
-307
lines changed

Trie/ReadMe.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@ Tries are very useful for certain situations. Here are some of the advantages:
2727

2828
```swift
2929
func contains(word: String) -> Bool {
30-
guard !word.isEmpty else { return false }
30+
guard !word.isEmpty else { return false }
3131

32-
// 1
33-
var currentNode = root
32+
// 1
33+
var currentNode = root
3434

35-
// 2
36-
var characters = Array(word.lowercased().characters)
37-
var currentIndex = 0
35+
// 2
36+
var characters = Array(word.lowercased())
37+
var currentIndex = 0
3838

39-
// 3
40-
while currentIndex < characters.count,
41-
let child = currentNode.children[characters[currentIndex]] {
42-
43-
currentNode = child
44-
currentIndex += 1
45-
}
46-
47-
// 4
48-
if currentIndex == characters.count && currentNode.isTerminating {
49-
return true
50-
} else {
51-
return false
52-
}
39+
// 3
40+
while currentIndex < characters.count,
41+
let child = currentNode.children[characters[currentIndex]] {
42+
43+
currentNode = child
44+
currentIndex += 1
45+
}
46+
47+
// 4
48+
if currentIndex == characters.count && currentNode.isTerminating {
49+
return true
50+
} else {
51+
return false
52+
}
5353
}
5454
```
5555

@@ -74,7 +74,7 @@ func insert(word: String) {
7474
var currentNode = root
7575

7676
// 2
77-
for character in word.lowercased().characters {
77+
for character in word.lowercased() {
7878
// 3
7979
if let childNode = currentNode.children[character] {
8080
currentNode = childNode

Trie/Trie/Trie.xcodeproj/project.pbxproj

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787
EB798E191DFEF79900F0628D /* TrieUITests */,
8888
EB798DFB1DFEF79900F0628D /* Products */,
8989
);
90+
indentWidth = 2;
9091
sourceTree = "<group>";
92+
tabWidth = 2;
9193
};
9294
EB798DFB1DFEF79900F0628D /* Products */ = {
9395
isa = PBXGroup;
@@ -195,20 +197,23 @@
195197
isa = PBXProject;
196198
attributes = {
197199
LastSwiftUpdateCheck = 0810;
198-
LastUpgradeCheck = 0820;
200+
LastUpgradeCheck = 1000;
199201
ORGANIZATIONNAME = "Rick Zaccone";
200202
TargetAttributes = {
201203
EB798DF91DFEF79900F0628D = {
202204
CreatedOnToolsVersion = 8.1;
205+
LastSwiftMigration = 1000;
203206
ProvisioningStyle = Automatic;
204207
};
205208
EB798E0A1DFEF79900F0628D = {
206209
CreatedOnToolsVersion = 8.1;
210+
LastSwiftMigration = 1000;
207211
ProvisioningStyle = Automatic;
208212
TestTargetID = EB798DF91DFEF79900F0628D;
209213
};
210214
EB798E151DFEF79900F0628D = {
211215
CreatedOnToolsVersion = 8.1;
216+
LastSwiftMigration = 1000;
212217
ProvisioningStyle = Automatic;
213218
TestTargetID = EB798DF91DFEF79900F0628D;
214219
};
@@ -326,15 +331,23 @@
326331
CLANG_CXX_LIBRARY = "libc++";
327332
CLANG_ENABLE_MODULES = YES;
328333
CLANG_ENABLE_OBJC_ARC = YES;
334+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
329335
CLANG_WARN_BOOL_CONVERSION = YES;
336+
CLANG_WARN_COMMA = YES;
330337
CLANG_WARN_CONSTANT_CONVERSION = YES;
338+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
331339
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
332340
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
333341
CLANG_WARN_EMPTY_BODY = YES;
334342
CLANG_WARN_ENUM_CONVERSION = YES;
335343
CLANG_WARN_INFINITE_RECURSION = YES;
336344
CLANG_WARN_INT_CONVERSION = YES;
345+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
346+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
347+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
337348
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
349+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
350+
CLANG_WARN_STRICT_PROTOTYPES = YES;
338351
CLANG_WARN_SUSPICIOUS_MOVE = YES;
339352
CLANG_WARN_SUSPICIOUS_MOVES = YES;
340353
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -376,15 +389,23 @@
376389
CLANG_CXX_LIBRARY = "libc++";
377390
CLANG_ENABLE_MODULES = YES;
378391
CLANG_ENABLE_OBJC_ARC = YES;
392+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
379393
CLANG_WARN_BOOL_CONVERSION = YES;
394+
CLANG_WARN_COMMA = YES;
380395
CLANG_WARN_CONSTANT_CONVERSION = YES;
396+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
381397
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
382398
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
383399
CLANG_WARN_EMPTY_BODY = YES;
384400
CLANG_WARN_ENUM_CONVERSION = YES;
385401
CLANG_WARN_INFINITE_RECURSION = YES;
386402
CLANG_WARN_INT_CONVERSION = YES;
403+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
404+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
405+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
387406
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
407+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
408+
CLANG_WARN_STRICT_PROTOTYPES = YES;
388409
CLANG_WARN_SUSPICIOUS_MOVE = YES;
389410
CLANG_WARN_SUSPICIOUS_MOVES = YES;
390411
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -418,7 +439,7 @@
418439
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
419440
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.Trie;
420441
PRODUCT_NAME = "$(TARGET_NAME)";
421-
SWIFT_VERSION = 3.0;
442+
SWIFT_VERSION = 4.2;
422443
};
423444
name = Debug;
424445
};
@@ -431,7 +452,7 @@
431452
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
432453
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.Trie;
433454
PRODUCT_NAME = "$(TARGET_NAME)";
434-
SWIFT_VERSION = 3.0;
455+
SWIFT_VERSION = 4.2;
435456
};
436457
name = Release;
437458
};
@@ -445,7 +466,7 @@
445466
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
446467
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieTests;
447468
PRODUCT_NAME = "$(TARGET_NAME)";
448-
SWIFT_VERSION = 3.0;
469+
SWIFT_VERSION = 4.2;
449470
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Trie.app/Contents/MacOS/Trie";
450471
};
451472
name = Debug;
@@ -460,7 +481,7 @@
460481
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
461482
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieTests;
462483
PRODUCT_NAME = "$(TARGET_NAME)";
463-
SWIFT_VERSION = 3.0;
484+
SWIFT_VERSION = 4.2;
464485
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Trie.app/Contents/MacOS/Trie";
465486
};
466487
name = Release;
@@ -474,7 +495,7 @@
474495
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
475496
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieUITests;
476497
PRODUCT_NAME = "$(TARGET_NAME)";
477-
SWIFT_VERSION = 3.0;
498+
SWIFT_VERSION = 4.2;
478499
TEST_TARGET_NAME = Trie;
479500
};
480501
name = Debug;
@@ -488,7 +509,7 @@
488509
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
489510
PRODUCT_BUNDLE_IDENTIFIER = edu.bucknell.zaccone.TrieUITests;
490511
PRODUCT_NAME = "$(TARGET_NAME)";
491-
SWIFT_VERSION = 3.0;
512+
SWIFT_VERSION = 4.2;
492513
TEST_TARGET_NAME = Trie;
493514
};
494515
name = Release;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Trie/Trie/Trie/AppDelegate.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import Cocoa
1111
@NSApplicationMain
1212
class AppDelegate: NSObject, NSApplicationDelegate {
1313

14-
func applicationDidFinishLaunching(_ aNotification: Notification) {
15-
// Insert code here to initialize your application
16-
}
14+
func applicationDidFinishLaunching(_ aNotification: Notification) {
15+
// Insert code here to initialize your application
16+
}
1717

18-
func applicationWillTerminate(_ aNotification: Notification) {
19-
// Insert code here to tear down your application
20-
}
18+
func applicationWillTerminate(_ aNotification: Notification) {
19+
// Insert code here to tear down your application
20+
}
2121

2222
}

0 commit comments

Comments
 (0)