In this video we look at Reference Counting and RefCell smart pointers to introduce interior mutability and shared references for our Binary Search Tree. Our implementation of the insertion algorithm is refactored (iterative and recursive) using the new Rc and RefCell pointer with interior mutability (dynamic borrowing). We will also refactor our inorder traversal algorithm to use the Rc/RefCell node pointers. We learn a little bit about the Heap and the Stack, how the pointers are setup and dynamically borrowed (in the case of RefCells) in memory and what happens when we call clone. Additionally, we make use of type aliasing to remove and refactor a lot of verbose code by referring to Boxed Nodes or Reference Count RefCell Nodes as simply Node Pointers (NodePtr).
Part 1: Insertion Algorithm [ Ссылка ]
Part 2: Level Order Traversal [ Ссылка ]
Part 3: Inorder Traversal [ Ссылка ]
Part 4: Tree Traversal Iterators [ Ссылка ]
Part 5: Tree Traversals with Rc [ Ссылка ]
Part 6: Debugging Reference Counters [ Ссылка ]
Part 7: Handling Reference Cycles [ Ссылка ]
↠ References:
Interior Mutability: [ Ссылка ]
Reference Counters: [ Ссылка ]
std::cell: [ Ссылка ]
Borrow Trait: [ Ссылка ]
Pointers: [ Ссылка ]
Visualizing Memory Management: [ Ссылка ]
· Binary Search Tree: [ Ссылка ]
· ref Pattern: [ Ссылка ]
· Rust Cheatsheet: [ Ссылка ]
· std::boxed::Box: [ Ссылка ]
· Box: [ Ссылка ]
↠ Dotfiles: [ Ссылка ]
↠ Twitter: @nyxtom [ Ссылка ]
↠ Channel: [ Ссылка ]
Cheers! 🍻
🦀 #rust #rustlang #rustprogramming #exercises #leetcode #programming
Ещё видео!