-// nodeReader gives the built nodes of a tree.
-type nodeReader interface {
- Built(level, index int) (bool, error)
- Node(level, index int) (Node, bool, error)
-}
-
-// View is a list of tree nodes that covers messages 0 to end-1 without a gap,
-// oldest first. Each new message appends its leaf as a line. Once the size of
-// the view goes above high, one batch merges the most due sibling pairs until
-// the size is at most low. A batch merges only pairs whose parent is built. If
-// the batch cannot get to low, it continues at each new message until it does.
-//
-// The view keeps the nodes of its built lines in memory, so its size and its
-// text need no read of the tree. The size of a line is the size of its node
-// text, or the size of the pending text when the node is not built.
-//
-// For the sibling pair (l, i) and (l, i+1), due is (T - last) / 2^l, with T the
-// number of messages and last the ID of the last message of the pair. That is
-// how long ago the pair ended, measured in its own line size. With a budget of
-// the length of the rollback push list of the reference design, this order
-// makes the same merges as the push. The oldest pair wins a tie.
-type View struct {
- high int
- low int
- lines []nodeKey
- nodes map[nodeKey]Node
- end int
- merging bool
-}
-
-// viewState is the saved form of a View. The limits are not part of it.
-type viewState struct {
- Lines [][2]int `json:"lines"`
- Merging bool `json:"merging"`
-}
-