Skip to content

Commit 63dc3b4

Browse files
committed
Chapter 3: Add summary and links commit for Exercise 3-6
1 parent 57f3f73 commit 63dc3b4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

chapter-3/3.6-c++/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,16 @@ TODO: measure performance between the two versions.
1616
### Exercise 3-6
1717
Write a C++ version that uses only classes and the `string` data type, but no other advanced library facilities.
1818
Compare it in style and speed to the STL versions.
19+
20+
*Answer:* I approached this incrementally, doing it type by type.
21+
The changes are part of the following commits:
22+
- `Suffixes` - `std::vector<std::string>` to `class Suffixes` that uses a Linked list under the hood - [`#bd84f3e`](https://github.com/asankov/the-practice-of-programming/commit/bd84f3e6112069e25f56e798d08384ea3d5aa50b)
23+
- `State` - `std::map<Prefix, Suffixes>` to `class StateMap` that uses a hash map under the hood - [`#e84ba3d`](https://github.com/asankov/the-practice-of-programming/commit/e84ba3dd3f3f8fa7e9f831475b3e5499a129da47)
24+
- `Prefix` - `std::deque<std::string>` to `class Prefix` that uses a simple array under the hood - [`#57f3f73`](https://github.com/asankov/the-practice-of-programming/commit/57f3f73a70cf9700a7559c694c8c7010afaca19d)
25+
26+
The first one was easy, the other two took more time, because there were more work that needed to be done for them.
27+
The solution is really close to the C one, with the only difference that the details are encapsulated, behind the hoods of the classes.
28+
But they are still there and the developers need to care for them.
29+
In terms of the actual implementation that uses these structs and classes - not much changed, because I kept the contracts more or less the same.
30+
31+
Although it was fun implementing this stuff and hitting all the obstacles, in an actual world situation I would rarely choose the custom implementations over the library ones.

0 commit comments

Comments
 (0)