2 ms·
Why a 2D array makes sense: many people using multiplexers like this seem to use them in a 2x2 or 3x3 grid. You could easily represent panes like that by making
by jeroenhd 5y ago
Why a 2D array makes sense: many people using multiplexers like this seem to use them in a 2x2 or 3x3 grid. You could easily represent panes like that by making an HTML-like grid where each row and column contains a number of which pane it belongs to.
As for why trees seem to be a novel concept: the code is written in Rust, and tree algorithms specifically are hard to do in the traditional way (pointers to pointers being moved around) without unsafe code. While you're at it, you may just as well explain trees I guess.
Of course Rust trees can be done, but the resulting data structure is often unwieldy and ugly. When I'm writing Rust, I tend to avoid writing structures like that because I don't want to deal with Box<Arc<RefCell<X>>> or whatever the correct type is for writing mutable tree structures.
- von_lohengramm 5y agoAnecdotally, I've never used or seen anyone use a pure NxN grid. It's always a series of horizontal or vertical splits (a tree). I'll admit that this being Rust is likely the cause, but this is a simple binary tree. There's no need for backpointers or any troublesome algorithms or anything. It's just a tad annoying that Rust pushes people towards crappy solutions by making the better solution _spooky and dangerous_ when said solution doesn't even involve the _spooky and dangerous_ `unsafe` keyword.