From eb2245db21d3110cdfb4d6f0e0d43d0045fb01ca Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 26 Jun 2024 13:42:50 +0000 Subject: [PATCH 1/3] posts: union-find: fix typos --- content/posts/2024-06-24-union-find/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/posts/2024-06-24-union-find/index.md b/content/posts/2024-06-24-union-find/index.md index e358205..edff8b6 100644 --- a/content/posts/2024-06-24-union-find/index.md +++ b/content/posts/2024-06-24-union-find/index.md @@ -86,7 +86,7 @@ A naive Implementation of `find(...)` is simple enough to write: ```python def find(self, elem: int) -> int: # If `elem` is its own parent, then it is the root of the tree - if (parent: = self._parent[elem]) == elem: + if (parent := self._parent[elem]) == elem: return elem # Otherwise, recurse on the parent return self.find(parent) @@ -94,11 +94,11 @@ def find(self, elem: int) -> int: However, going back up the chain of parents each time we want to find the root node (an `O(n)` operation) would make for disastrous performance. Instead we can -do a small optimization called _path splitting. +do a small optimization called _path splitting_. ```python def find(self, elem: int) -> int: - while (parent: = self._parent[elem]) != elem: + while (parent := self._parent[elem]) != elem: # Replace each parent link by a link to the grand-parent elem, self._parent[elem] = parent, self._parent[parent] return elem From 3226918995e0bb88f423a6a2dd53b34a760fb055 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 26 Jun 2024 13:43:55 +0000 Subject: [PATCH 2/3] posts: polymorphic-flyweight: fix typo --- content/posts/2020-07-22-polymorphic-flyweight-cpp/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/posts/2020-07-22-polymorphic-flyweight-cpp/index.md b/content/posts/2020-07-22-polymorphic-flyweight-cpp/index.md index 5ff4b1f..2311002 100644 --- a/content/posts/2020-07-22-polymorphic-flyweight-cpp/index.md +++ b/content/posts/2020-07-22-polymorphic-flyweight-cpp/index.md @@ -68,7 +68,7 @@ public: const std::type_index lhs_i(lhs); const std::type_index rhs_i(rhs); if (lhs_i != rhs_i) - returh lhs_i < rhs_i; + return lhs_i < rhs_i; // We are now assured that both classes have the same type return less_than(rhs); } From dfdd65cd27166b612e99b76149180677a84b1291 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 26 Jun 2024 13:44:23 +0000 Subject: [PATCH 3/3] posts: generic-flyweight: fix typo --- content/posts/2020-07-16-generic-flyweight-cpp/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/posts/2020-07-16-generic-flyweight-cpp/index.md b/content/posts/2020-07-16-generic-flyweight-cpp/index.md index 303b3db..3ca1e3a 100644 --- a/content/posts/2020-07-16-generic-flyweight-cpp/index.md +++ b/content/posts/2020-07-16-generic-flyweight-cpp/index.md @@ -16,7 +16,7 @@ favorite: false The flyweight is a well-known [GoF](https://en.wikipedia.org/wiki/Design_Patterns) design pattern. -It's intent is to minimize memory usage by reducing the number of instantiations +Its intent is to minimize memory usage by reducing the number of instantiations of a given object. I will show you how to implement a robust flyweight in C++, as well as a way to