Use a binary tree/heap to represent panes #18192

Open
opened 2026-01-31 06:06:26 +00:00 by claunia · 0 comments
Owner

Originally created by @lhecker on GitHub (Aug 17, 2022).

Problem

The Pane class acts simultaneously as the data model to represent actual panes and as splits which contain nothing but exactly 2 child panes and a split ratio / direction. In a sense Pane represents both a leaf and internal nodes in a binary tree simultaneously. Member functions of Pane iterating through that tree are complex and make changes difficult (#13306), as iteration happens almost exclusively via recursion, making retaining state cumbersome.

Proposal

Let's implement a binary heap class that works independently of Pane. This would allow us to use regular text-book algorithms for its implementation. Internal nodes of the heap would retain split ratios and directions and leaf nodes of the heap contain shared_ptr<Pane> references. Traversal/iteration would also be simplified. This separate heap would be cheap to clone, allowing us to implement things like UI state persistence (#13306) more easily.

Originally created by @lhecker on GitHub (Aug 17, 2022). # Problem The `Pane` class acts simultaneously as the data model to represent actual panes and as splits which contain nothing but exactly 2 child panes and a split ratio / direction. In a sense `Pane` represents both a leaf and internal nodes in a binary tree simultaneously. Member functions of `Pane` iterating through that tree are complex and make changes difficult (#13306), as iteration happens almost exclusively via recursion, making retaining state cumbersome. # Proposal Let's implement a binary heap class that works independently of `Pane`. This would allow us to use regular text-book algorithms for its implementation. Internal nodes of the heap would retain split ratios and directions and leaf nodes of the heap contain `shared_ptr<Pane>` references. Traversal/iteration would also be simplified. This separate heap would be cheap to clone, allowing us to implement things like UI state persistence (#13306) more easily.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18192