Skip to content

Commit 9eac510

Browse files
committed
Added a ReadMe file.
1 parent 5021bc7 commit 9eac510

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

Trie/Trie/Trie.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
EB798E2A1DFEF81400F0628D /* Trie.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB798E281DFEF81400F0628D /* Trie.swift */; };
1818
EB798E2C1DFEF90B00F0628D /* dictionary.txt in Resources */ = {isa = PBXBuildFile; fileRef = EB798E2B1DFEF90B00F0628D /* dictionary.txt */; };
1919
EB798E2D1DFEF90B00F0628D /* dictionary.txt in Resources */ = {isa = PBXBuildFile; fileRef = EB798E2B1DFEF90B00F0628D /* dictionary.txt */; };
20+
EB8369AD1E15C5710003A7F8 /* ReadMe.md in Sources */ = {isa = PBXBuildFile; fileRef = EB8369AC1E15C5710003A7F8 /* ReadMe.md */; };
2021
/* End PBXBuildFile section */
2122

2223
/* Begin PBXContainerItemProxy section */
@@ -51,6 +52,7 @@
5152
EB798E1C1DFEF79900F0628D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5253
EB798E281DFEF81400F0628D /* Trie.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Trie.swift; sourceTree = "<group>"; };
5354
EB798E2B1DFEF90B00F0628D /* dictionary.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dictionary.txt; sourceTree = "<group>"; };
55+
EB8369AC1E15C5710003A7F8 /* ReadMe.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = ReadMe.md; sourceTree = "<group>"; };
5456
/* End PBXFileReference section */
5557

5658
/* Begin PBXFrameworksBuildPhase section */
@@ -101,6 +103,7 @@
101103
EB798DFC1DFEF79900F0628D /* Trie */ = {
102104
isa = PBXGroup;
103105
children = (
106+
EB8369AC1E15C5710003A7F8 /* ReadMe.md */,
104107
EB798DFD1DFEF79900F0628D /* AppDelegate.swift */,
105108
EB798DFF1DFEF79900F0628D /* ViewController.swift */,
106109
EB798E011DFEF79900F0628D /* Assets.xcassets */,
@@ -267,6 +270,7 @@
267270
files = (
268271
EB798E291DFEF81400F0628D /* Trie.swift in Sources */,
269272
EB798E001DFEF79900F0628D /* ViewController.swift in Sources */,
273+
EB8369AD1E15C5710003A7F8 /* ReadMe.md in Sources */,
270274
EB798DFE1DFEF79900F0628D /* AppDelegate.swift in Sources */,
271275
);
272276
runOnlyForDeploymentPostprocessing = 0;

Trie/Trie/Trie/ReadMe.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changes
2+
3+
- Corrected a spelling error in a comment.
4+
5+
- Got rid of the `get` syntax for a read only property as the coding guidelines suggest.
6+
7+
- Changed several tests so that they are more Swift-like. That is, they now feel like they are using the features of the language better.
8+
9+
- Fixed a problem in the test method `testRemovePerformance`. The `measure` method runs the block of code 10 times. Previously, all words would get removed after the first run and the next 9 runs were very fast because there was nothing to do! That is corrected now.
10+
11+
- Made the `Trie` class a subclass of `NSObject` and had it conform to `NSCoding`. Added a test to verify that this works.
12+
13+
---
14+
15+
I wasn't able to figure out how to recursively archive the trie. Instead, I tried Kelvin's suggestion to use the `words` property to create an array of words in the trie, then archiving the array.
16+
17+
There are a couple of nice aspects to this approach.
18+
19+
- The `TrieNode` class can remain generic since it doesn't need to conform to `NSCoding`.
20+
21+
- It doesn't require much new code.
22+
23+
There are several downsides though.
24+
25+
- The size of the archived words is three times the size of the original file of words! Did I do this right? The tests pass, so it seems correct. I question whether archiving is worth the effort if the resulting archive is so much larger than the original file.
26+
27+
- I would expect that archiving the trie would result in a file that was smaller than the original since a trie doesn't repeat leading character sequences when they are the same.
28+
29+
- This requires that the trie get reconstructed when it is unarchived.
30+
31+
- My gut tells me that it would be faster to archive and unarchive the trie itself, but I don't have any hard data to support this.
32+
33+
I would like to see code that recursively archives the trie so we can compare the performance.

0 commit comments

Comments
 (0)