{"action":"created","comment":{"url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/comments/92197241","pull_request_review_id":12707146,"id":92197241,"diff_hunk":"@@ -0,0 +1,207 @@\n+//\n+//  Trie.swift\n+//  Trie\n+//\n+//  Created by Rick Zaccone on 2016-12-12.\n+//  Copyright © 2016 Rick Zaccone. All rights reserved.\n+//\n+\n+import Foundation\n+\n+\n+/// A node in the trie\n+class TrieNode<T: Hashable> {\n+    var value: T?\n+    weak var parentNode: TrieNode?\n+    var children: [T: TrieNode] = [:]\n+    var isTerminating = false\n+    var isLeaf: Bool {\n+        get {\n+            return children.count == 0\n+        }\n+    }\n+\n+    /// Initializes a node.\n+    ///\n+    /// - Parameters:\n+    ///   - value: The value that goes into the node\n+    ///   - parentNode: A reference to this node's parent\n+    init(value: T? = nil, parentNode: TrieNode? = nil) {\n+        self.value = value\n+        self.parentNode = parentNode\n+    }\n+\n+    /// Adds a child node to self.  If the child is already present,\n+    /// do nothing.\n+    ///\n+    /// - Parameter value: The item to be added to this node.\n+    func add(value: T) {\n+        guard children[value] == nil else {\n+            return\n+        }\n+        children[value] = TrieNode(value: value, parentNode: self)\n+    }\n+}\n+\n+/// A trie data structure containing words.  Each node is a single\n+/// character of a word.\n+class Trie {\n+    typealias Node = TrieNode<Character>\n+    /// The number of words in the trie\n+    public var count: Int {\n+        return wordCount\n+    }\n+    /// Is the trie empty?\n+    public var isEmpty: Bool {\n+        return wordCount == 0\n+    }\n+    /// All words currently in the trie\n+    public var words: [String] {\n+        return wordsInSubtrie(rootNode: root, partialWord: \"\")\n+    }\n+    fileprivate let root: Node\n+    fileprivate var wordCount: Int\n+\n+    /// Creats an empty trie.\n+    init() {\n+        root = Node()\n+        wordCount = 0\n+    }\n+}\n+\n+// MARK: - Adds methods: insert, remove, contains\n+extension Trie {\n+\n+    /// Inserts a word into the trie.  If the word is already present,\n+    /// there is no change.\n+    ///\n+    /// - Parameter word: the word to be inserted.\n+    func insert(word: String) {\n+        guard !word.isEmpty else {\n+            return\n+        }\n+        var currentNode = root\n+        let charactersInWord = Array(word.lowercased().characters)\n+        var index = 0\n+        while index < charactersInWord.count {\n+            let character = charactersInWord[index]\n+            if let childNode = currentNode.children[character] {\n+                currentNode = childNode\n+            } else {\n+                currentNode.add(value: character)\n+                currentNode = currentNode.children[character]!\n+            }\n+            index += 1\n+        }\n+        // Word already present?\n+        guard !currentNode.isTerminating else {\n+            return\n+        }\n+        self.wordCount += 1","path":"Trie/Trie/Trie/Trie.swift","position":100,"original_position":100,"commit_id":"24fa81839a45e24a6d5600c774fce3b730eb4de1","original_commit_id":"24fa81839a45e24a6d5600c774fce3b730eb4de1","user":{"login":"kelvinlauKL","id":11384608,"avatar_url":"https://avatars.githubusercontent.com/u/11384608?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinlauKL","html_url":"https://github.com/kelvinlauKL","followers_url":"https://api.github.com/users/kelvinlauKL/followers","following_url":"https://api.github.com/users/kelvinlauKL/following{/other_user}","gists_url":"https://api.github.com/users/kelvinlauKL/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinlauKL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinlauKL/subscriptions","organizations_url":"https://api.github.com/users/kelvinlauKL/orgs","repos_url":"https://api.github.com/users/kelvinlauKL/repos","events_url":"https://api.github.com/users/kelvinlauKL/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinlauKL/received_events","type":"User","site_admin":false},"body":"Unnecessary reference to `self`.","created_at":"2016-12-13T15:50:21Z","updated_at":"2016-12-13T15:50:21Z","html_url":"https://github.com/raywenderlich/swift-algorithm-club/pull/313#discussion_r92197241","pull_request_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313","_links":{"self":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/comments/92197241"},"html":{"href":"https://github.com/raywenderlich/swift-algorithm-club/pull/313#discussion_r92197241"},"pull_request":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313"}}},"pull_request":{"url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313","id":97631268,"html_url":"https://github.com/raywenderlich/swift-algorithm-club/pull/313","diff_url":"https://github.com/raywenderlich/swift-algorithm-club/pull/313.diff","patch_url":"https://github.com/raywenderlich/swift-algorithm-club/pull/313.patch","issue_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/issues/313","number":313,"state":"open","locked":false,"title":"I created an Xcode project with my changes.  It makes it easier to","user":{"login":"rzaccone","id":7754486,"avatar_url":"https://avatars.githubusercontent.com/u/7754486?v=3","gravatar_id":"","url":"https://api.github.com/users/rzaccone","html_url":"https://github.com/rzaccone","followers_url":"https://api.github.com/users/rzaccone/followers","following_url":"https://api.github.com/users/rzaccone/following{/other_user}","gists_url":"https://api.github.com/users/rzaccone/gists{/gist_id}","starred_url":"https://api.github.com/users/rzaccone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzaccone/subscriptions","organizations_url":"https://api.github.com/users/rzaccone/orgs","repos_url":"https://api.github.com/users/rzaccone/repos","events_url":"https://api.github.com/users/rzaccone/events{/privacy}","received_events_url":"https://api.github.com/users/rzaccone/received_events","type":"User","site_admin":false},"body":"I created an Xcode project with my changes.  It makes it easier to test and the playground was crashing!","created_at":"2016-12-12T20:54:24Z","updated_at":"2016-12-13T16:02:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef3eff681df1190dd1d270b2e8bdd24bf43749cf","assignee":{"login":"kelvinlauKL","id":11384608,"avatar_url":"https://avatars.githubusercontent.com/u/11384608?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinlauKL","html_url":"https://github.com/kelvinlauKL","followers_url":"https://api.github.com/users/kelvinlauKL/followers","following_url":"https://api.github.com/users/kelvinlauKL/following{/other_user}","gists_url":"https://api.github.com/users/kelvinlauKL/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinlauKL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinlauKL/subscriptions","organizations_url":"https://api.github.com/users/kelvinlauKL/orgs","repos_url":"https://api.github.com/users/kelvinlauKL/repos","events_url":"https://api.github.com/users/kelvinlauKL/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinlauKL/received_events","type":"User","site_admin":false},"assignees":[{"login":"kelvinlauKL","id":11384608,"avatar_url":"https://avatars.githubusercontent.com/u/11384608?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinlauKL","html_url":"https://github.com/kelvinlauKL","followers_url":"https://api.github.com/users/kelvinlauKL/followers","following_url":"https://api.github.com/users/kelvinlauKL/following{/other_user}","gists_url":"https://api.github.com/users/kelvinlauKL/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinlauKL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinlauKL/subscriptions","organizations_url":"https://api.github.com/users/kelvinlauKL/orgs","repos_url":"https://api.github.com/users/kelvinlauKL/repos","events_url":"https://api.github.com/users/kelvinlauKL/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinlauKL/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313/commits","review_comments_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313/comments","review_comment_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/comments{/number}","comments_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/issues/313/comments","statuses_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/statuses/24fa81839a45e24a6d5600c774fce3b730eb4de1","head":{"label":"rzaccone:master","ref":"master","sha":"24fa81839a45e24a6d5600c774fce3b730eb4de1","user":{"login":"rzaccone","id":7754486,"avatar_url":"https://avatars.githubusercontent.com/u/7754486?v=3","gravatar_id":"","url":"https://api.github.com/users/rzaccone","html_url":"https://github.com/rzaccone","followers_url":"https://api.github.com/users/rzaccone/followers","following_url":"https://api.github.com/users/rzaccone/following{/other_user}","gists_url":"https://api.github.com/users/rzaccone/gists{/gist_id}","starred_url":"https://api.github.com/users/rzaccone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzaccone/subscriptions","organizations_url":"https://api.github.com/users/rzaccone/orgs","repos_url":"https://api.github.com/users/rzaccone/repos","events_url":"https://api.github.com/users/rzaccone/events{/privacy}","received_events_url":"https://api.github.com/users/rzaccone/received_events","type":"User","site_admin":false},"repo":{"id":76285496,"name":"swift-algorithm-club","full_name":"rzaccone/swift-algorithm-club","owner":{"login":"rzaccone","id":7754486,"avatar_url":"https://avatars.githubusercontent.com/u/7754486?v=3","gravatar_id":"","url":"https://api.github.com/users/rzaccone","html_url":"https://github.com/rzaccone","followers_url":"https://api.github.com/users/rzaccone/followers","following_url":"https://api.github.com/users/rzaccone/following{/other_user}","gists_url":"https://api.github.com/users/rzaccone/gists{/gist_id}","starred_url":"https://api.github.com/users/rzaccone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzaccone/subscriptions","organizations_url":"https://api.github.com/users/rzaccone/orgs","repos_url":"https://api.github.com/users/rzaccone/repos","events_url":"https://api.github.com/users/rzaccone/events{/privacy}","received_events_url":"https://api.github.com/users/rzaccone/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rzaccone/swift-algorithm-club","description":"Algorithms and data structures in Swift, with explanations!","fork":true,"url":"https://api.github.com/repos/rzaccone/swift-algorithm-club","forks_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/forks","keys_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/teams","hooks_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/hooks","issue_events_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/issues/events{/number}","events_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/events","assignees_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/assignees{/user}","branches_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/branches{/branch}","tags_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/tags","blobs_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/git/refs{/sha}","trees_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/statuses/{sha}","languages_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/languages","stargazers_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/stargazers","contributors_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/contributors","subscribers_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/subscribers","subscription_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/subscription","commits_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/commits{/sha}","git_commits_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/git/commits{/sha}","comments_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/comments{/number}","issue_comment_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/issues/comments{/number}","contents_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/contents/{+path}","compare_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/merges","archive_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/downloads","issues_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/issues{/number}","pulls_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/pulls{/number}","milestones_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/milestones{/number}","notifications_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/labels{/name}","releases_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/releases{/id}","deployments_url":"https://api.github.com/repos/rzaccone/swift-algorithm-club/deployments","created_at":"2016-12-12T18:50:46Z","updated_at":"2016-12-12T18:50:48Z","pushed_at":"2016-12-12T20:46:30Z","git_url":"git://github.com/rzaccone/swift-algorithm-club.git","ssh_url":"git@github.com:rzaccone/swift-algorithm-club.git","clone_url":"https://github.com/rzaccone/swift-algorithm-club.git","svn_url":"https://github.com/rzaccone/swift-algorithm-club","homepage":null,"size":7058,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"raywenderlich:master","ref":"master","sha":"24b721a7326bdfc03a47d750e172811421c0d4fb","user":{"login":"raywenderlich","id":4722515,"avatar_url":"https://avatars.githubusercontent.com/u/4722515?v=3","gravatar_id":"","url":"https://api.github.com/users/raywenderlich","html_url":"https://github.com/raywenderlich","followers_url":"https://api.github.com/users/raywenderlich/followers","following_url":"https://api.github.com/users/raywenderlich/following{/other_user}","gists_url":"https://api.github.com/users/raywenderlich/gists{/gist_id}","starred_url":"https://api.github.com/users/raywenderlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raywenderlich/subscriptions","organizations_url":"https://api.github.com/users/raywenderlich/orgs","repos_url":"https://api.github.com/users/raywenderlich/repos","events_url":"https://api.github.com/users/raywenderlich/events{/privacy}","received_events_url":"https://api.github.com/users/raywenderlich/received_events","type":"Organization","site_admin":false},"repo":{"id":50447720,"name":"swift-algorithm-club","full_name":"raywenderlich/swift-algorithm-club","owner":{"login":"raywenderlich","id":4722515,"avatar_url":"https://avatars.githubusercontent.com/u/4722515?v=3","gravatar_id":"","url":"https://api.github.com/users/raywenderlich","html_url":"https://github.com/raywenderlich","followers_url":"https://api.github.com/users/raywenderlich/followers","following_url":"https://api.github.com/users/raywenderlich/following{/other_user}","gists_url":"https://api.github.com/users/raywenderlich/gists{/gist_id}","starred_url":"https://api.github.com/users/raywenderlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raywenderlich/subscriptions","organizations_url":"https://api.github.com/users/raywenderlich/orgs","repos_url":"https://api.github.com/users/raywenderlich/repos","events_url":"https://api.github.com/users/raywenderlich/events{/privacy}","received_events_url":"https://api.github.com/users/raywenderlich/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/raywenderlich/swift-algorithm-club","description":"Algorithms and data structures in Swift, with explanations!","fork":false,"url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club","forks_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/forks","keys_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/keys{/key_id}","collaborators_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/teams","hooks_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/hooks","issue_events_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/issues/events{/number}","events_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/events","assignees_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/assignees{/user}","branches_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/branches{/branch}","tags_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/tags","blobs_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/git/refs{/sha}","trees_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/git/trees{/sha}","statuses_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/statuses/{sha}","languages_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/languages","stargazers_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/stargazers","contributors_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/contributors","subscribers_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/subscribers","subscription_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/subscription","commits_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/commits{/sha}","git_commits_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/git/commits{/sha}","comments_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/comments{/number}","issue_comment_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/issues/comments{/number}","contents_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/contents/{+path}","compare_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/compare/{base}...{head}","merges_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/merges","archive_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/downloads","issues_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/issues{/number}","pulls_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls{/number}","milestones_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/milestones{/number}","notifications_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/labels{/name}","releases_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/releases{/id}","deployments_url":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/deployments","created_at":"2016-01-26T17:56:12Z","updated_at":"2016-12-13T15:29:46Z","pushed_at":"2016-12-12T20:54:24Z","git_url":"git://github.com/raywenderlich/swift-algorithm-club.git","ssh_url":"git@github.com:raywenderlich/swift-algorithm-club.git","clone_url":"https://github.com/raywenderlich/swift-algorithm-club.git","svn_url":"https://github.com/raywenderlich/swift-algorithm-club","homepage":null,"size":7808,"stargazers_count":9780,"watchers_count":9780,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1233,"mirror_url":null,"open_issues_count":37,"forks":1233,"open_issues":37,"watchers":9780,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313"},"html":{"href":"https://github.com/raywenderlich/swift-algorithm-club/pull/313"},"issue":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/issues/313"},"comments":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/issues/313/comments"},"review_comments":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313/comments"},"review_comment":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/pulls/313/commits"},"statuses":{"href":"https://api.github.com/repos/raywenderlich/swift-algorithm-club/statuses/24fa81839a45e24a6d5600c774fce3b730eb4de1"}}}}
{"actor":{"display_login":"kelvinlauKL"}}