Documentation
¶
Overview ¶
Package rope implements a "heavy-weight string", which represents very long strings more efficiently (especially when many concatenations are performed).
It may also need less memory if it contains repeated substrings, or if you use several large strings that are similar to each other.
Rope values are immutable, so each operation returns its result instead of modifying the receiver. This immutability also makes them thread-safe.
Index ¶
- Variables
- type Reader
- type Rope
- func (r Rope) Append(rhs ...Rope) Rope
- func (r Rope) AppendString(rhs ...string) Rope
- func (r Rope) At(idx int64) byte
- func (r Rope) Bytes() []byte
- func (r Rope) Depth() uint32
- func (r Rope) DropPostfix(end int64) Rope
- func (r Rope) DropPrefix(start int64) Rope
- func (r Rope) GoString() string
- func (r Rope) Len() int64
- func (r Rope) ReadAt(p []byte, off int64) (n int, err error)
- func (r Rope) Rebalance() Rope
- func (r Rope) Repeat(count int64) Rope
- func (r Rope) Slice(start, end int64) Rope
- func (r Rope) String() string
- func (r Rope) Walk(f func(string) error) error
- func (r Rope) WriteTo(w io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
var MarkGoStringedRope = true
MarkGoStringedRope is a flag that, when enabled, prepends "/*Rope*/ " to the result of Rope.GoString(). This can be useful when debugging code using interface{} values, where Ropes and strings can coexist.
This should only ever be changed from init() functions, to ensure there are no data races.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an io.Reader that reads from a Rope.
type Rope ¶
type Rope struct {
// contains filtered or unexported fields
}
Rope implements a non-contiguous string. The zero value is an empty rope.
func (Rope) AppendString ¶
AppendString is like Append, but accepts strings.
func (Rope) Depth ¶
Depth returns the depth of the directed acyclic graph the Rope consists of internally
func (Rope) DropPostfix ¶
DropPostfix returns the prefix of a rope ending at end. It's analogous to str[:end].
If end <= 0, an empty Rope is returned.
func (Rope) DropPrefix ¶
DropPrefix returns a postfix of a rope, starting at index. It's analogous to str[start:].
If start >= r.Len(), an empty Rope is returned.
func (Rope) Slice ¶
Slice returns the substring of a Rope, analogous to str[start:end]. It is equivalent to r.DropPostfix(end).DropPrefix(start).
If start >= end, start >= r.Len() or end == 0, an empty Rope is returned.