Documentation
¶
Index ¶
- Variables
- type Node
- func (n *Node) At(pos int) byte
- func (n *Node) Count(start, end int, sep []byte) int
- func (n *Node) Each(fn func(n *Node))
- func (n *Node) EachLeaf(fn func(n *Node) bool) bool
- func (n *Node) IndexAllFunc(start, end int, sep []byte, fn func(idx int) bool)
- func (n *Node) Insert(pos int, value []byte)
- func (n *Node) Len() int
- func (n *Node) ReadAt(p []byte, off int64) (nread int, err error)
- func (n *Node) Rebalance()
- func (n *Node) Rebuild()
- func (n *Node) Remove(start, end int)
- func (n *Node) Slice(start, end int) []byte
- func (n *Node) SplitAt(i int) (*Node, *Node)
- func (n *Node) Value() []byte
- func (n *Node) WriteTo(w io.Writer) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ( // SplitLength is the threshold above which slices will be split into // separate nodes. SplitLength = 4096 * 4 // JoinLength is the threshold below which nodes will be merged into // slices. JoinLength = SplitLength / 2 // RebalanceRatio is the threshold used to trigger a rebuild during a // rebalance operation. RebalanceRatio = 1.2 )
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
A Node in the rope structure. If the kind is tLeaf, only the value and length are valid, and if the kind is tNode, only length, left, right are valid.
func New ¶
New returns a new rope node from the given byte slice. The underlying data is not copied so the user should ensure that it is okay to insert and delete from the input slice.
func (*Node) Count ¶
Count the number of occurrences of 'sep' in this rope in the range [start:end).
func (*Node) IndexAllFunc ¶
IndexAllFunc iterates through all occurrences of 'sep' in the range [start:end) and calls fn each time with the index of the occurrence. If 'fn' returns 'true' iteration is aborted and fn will no longer be called.
func (*Node) Rebalance ¶
func (n *Node) Rebalance()
Rebalance finds unbalanced nodes and rebuilds them.
func (*Node) Rebuild ¶
func (n *Node) Rebuild()
Rebuild rebuilds the entire rope structure, resulting in a balanced tree.
func (*Node) Slice ¶
Slice returns the range of the rope from [start:end). The returned slice is not copied.
func (*Node) SplitAt ¶
SplitAt splits the node at the given index and returns two new ropes corresponding to the left and right portions of the split.