From 63dc3b49aeeff327a0625dda231affe3d6997e2f Mon Sep 17 00:00:00 2001 From: asankov Date: Sun, 10 May 2020 04:15:54 +0300 Subject: [PATCH] Chapter 3: Add summary and links commit for Exercise 3-6 --- chapter-3/3.6-c++/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/chapter-3/3.6-c++/README.md b/chapter-3/3.6-c++/README.md index 4fa3768..dfa5de9 100644 --- a/chapter-3/3.6-c++/README.md +++ b/chapter-3/3.6-c++/README.md @@ -16,3 +16,16 @@ TODO: measure performance between the two versions. ### Exercise 3-6 Write a C++ version that uses only classes and the `string` data type, but no other advanced library facilities. Compare it in style and speed to the STL versions. + +*Answer:* I approached this incrementally, doing it type by type. +The changes are part of the following commits: +- `Suffixes` - `std::vector` to `class Suffixes` that uses a Linked list under the hood - [`#bd84f3e`](https://github.com/asankov/the-practice-of-programming/commit/bd84f3e6112069e25f56e798d08384ea3d5aa50b) +- `State` - `std::map` to `class StateMap` that uses a hash map under the hood - [`#e84ba3d`](https://github.com/asankov/the-practice-of-programming/commit/e84ba3dd3f3f8fa7e9f831475b3e5499a129da47) +- `Prefix` - `std::deque` to `class Prefix` that uses a simple array under the hood - [`#57f3f73`](https://github.com/asankov/the-practice-of-programming/commit/57f3f73a70cf9700a7559c694c8c7010afaca19d) + +The first one was easy, the other two took more time, because there were more work that needed to be done for them. +The solution is really close to the C one, with the only difference that the details are encapsulated, behind the hoods of the classes. +But they are still there and the developers need to care for them. +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. + +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. \ No newline at end of file