notes

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 3bd657bc513e1e72dbca7d6a8b3987f9a141efc3
parent 780bf0fde9e02bc65ca24f5116a2d78e4039f870
Author: ling0x <ling0x@users.noreply.github.com>
Date:   Fri, 11 Sep 2026 01:49:51 +0100

commands and articles

Diffstat:
Mcommands/rust.txt | 4++++
Adata_structure/vecdeque.txt | 37+++++++++++++++++++++++++++++++++++++
Areferences/articles/illegal_immigration.txt | 26++++++++++++++++++++++++++
3 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/commands/rust.txt b/commands/rust.txt @@ -41,3 +41,6 @@ cargo update Profile memory/perf: cargo flamegraph + +Documentation (Open in browser) +cargo doc -p <crate_name> --no-deps --open +\ No newline at end of file diff --git a/data_structure/vecdeque.txt b/data_structure/vecdeque.txt @@ -0,0 +1,36 @@ +=============================================================================== +VecDeque +=============================================================================== + +VecDeque stands for Vector Double-Ended Queue. + +It's a Rust standard library collection (std::collections::VecDeque<T>) that +lets you efficiently push and pop elements from both the front and the back — +unlike a regular Vec, which is only efficient at the back. + +A ring buffer (aka circular buffer) is the underlying data structure that makes +this possible. It's a fixed-size (or growable) contiguous block of memory that's +treated as if it wraps around — the end connects back to the beginning, like a +clock face. + +Memory layout (capacity 8): [ _ _ C D E _ _ _ ] + ↑ ↑ + head tail + +push_front(B) → [ _ B C D E _ _ _ ] +push_back(F) → [ _ B C D E F _ _ ] + + +If you keep pushing to the front and the head index would go negative, it just wraps to the last slot in the buffer instead: + +[ _ B C D E F _ _ ] +push_front(A) many times, eventually head wraps around: +[ F _ _ _ B C D E ] ← wrapped: F is logically "before" B now + ↑ tail ↑ head + + +The buffer only needs to resize (reallocate + reflow into a bigger contiguous +chunk) when it's actually full, same amortized-growth idea as Vec. + +You get O(1) operations at both ends, which is exactly what you want for things +like sliding windows, work queues, or BFS frontiers. +\ No newline at end of file diff --git a/references/articles/illegal_immigration.txt b/references/articles/illegal_immigration.txt @@ -0,0 +1,25 @@ +The thoughts of economist Milton Friedman on immigration: + +"If you have free immigration, in the way we had it before 1914, everybody +benefited. The people who were here benefited. The people who came benefited. +Because nobody would come unless he, or his family, thought he would do better +here than he would elsewhere. And, the new immigrants provided additional +resources, provided additional possibilities for the people already here. So +everybody can mutually benefit…. + +Look, for example, at the obvious, immediate, practical example of illegal +Mexican immigration. Now, that Mexican immigration, over the border, is a good +thing. It's a good thing for the illegal immigrants. It's a good thing for the +United States. It's a good thing for the citizens of the country. But, it's +only good so long as its illegal…. + +That's an interesting paradox to think about. Make it legal and it's no good. +Why? Because as long as it's illegal the people who come in do not qualify for +welfare, they don't qualify for social security, they don't qualify for the +other myriad of benefits that we pour out from our left pocket to our right +pocket. So long as they don't qualify they migrate to jobs. They take jobs +that most residents of this country are unwilling to take. They provide +employers with the kind of workers that they cannot get. They're hard workers, +they're good workers, and they are clearly better off." + +(My Reason magazine feature from March 2007 on the career of Milton Friedman.) +\ No newline at end of file