Compare commits

...

3 commits

Author SHA1 Message Date
Bruno BELANYI 3e416d0a39 posts: generic-flyweight: fix typo
All checks were successful
ci/woodpecker/push/deploy/2 Pipeline was successful
2024-06-26 13:44:23 +00:00
Bruno BELANYI 28e886ecd3 posts: polymorphic-flyweight: fix typo 2024-06-26 13:43:55 +00:00
Bruno BELANYI 8a8de126c1 posts: union-find: fix typo 2024-06-26 13:42:50 +00:00
3 changed files with 3 additions and 3 deletions

View file

@ -16,7 +16,7 @@ favorite: false
The flyweight is a well-known The flyweight is a well-known
[GoF](https://en.wikipedia.org/wiki/Design_Patterns) design pattern. [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. of a given object.
I will show you how to implement a robust flyweight in C++, as well as a way to I will show you how to implement a robust flyweight in C++, as well as a way to

View file

@ -68,7 +68,7 @@ public:
const std::type_index lhs_i(lhs); const std::type_index lhs_i(lhs);
const std::type_index rhs_i(rhs); const std::type_index rhs_i(rhs);
if (lhs_i != rhs_i) 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 // We are now assured that both classes have the same type
return less_than(rhs); return less_than(rhs);
} }

View file

@ -94,7 +94,7 @@ def find(self, elem: int) -> int:
However, going back up the chain of parents each time we want to find the root 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 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 ```python
def find(self, elem: int) -> int: def find(self, elem: int) -> int: