Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 3 Trie #208

Merged
merged 6 commits into from Sep 13, 2016
Merged

Swift 3 Trie #208

merged 6 commits into from Sep 13, 2016

Conversation

kelvinlauKL
Copy link
Member

@kelvinlauKL kelvinlauKL commented Sep 10, 2016

Also noticed that there are a lot of inconsistencies between the RW Swift style guide and the current implementation.

Going to refactor the Swift file in the playground. Here are a few changes that I hope to achieve:

  • Usage of computed properties rather than methods as much as possible. The current implementation still relies on Objective-C styling, which all getters/setters are required to be methods.

Here's an example of such a change:

// old implementation
func isRoot() -> Bool {
  return character == ""
}

// new implementation
var isRoot: Bool {
  return character == ""
}
  • Updating the naming for functions / parameters.
  • Updating method signatures - Will need a bit more investigation, but I feel the reliance on tuples is unnatural in this scenario.

Many of the methods return a tuple. For example:

func isPrefix(_ prefix: String) -> (node: Node?, found: Bool) { ... }

isPrefix is a method that checks the Trie to see if the argument exists in the Trie. If it exists, the method returns a node object and true. If it doesn't exist, the return is nil and false. The value the optional makes the boolean unnecessary.

  • Various little styling changes.
  • Creating a playground for the Trie implementation.
  • Updating the readme appropriately.

@chris-pilcher chris-pilcher mentioned this pull request Sep 10, 2016
71 tasks
@kelvinlauKL kelvinlauKL merged commit b4f2188 into master Sep 13, 2016
@kelvinlauKL kelvinlauKL deleted the Swift3Trie branch September 15, 2016 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant