Imports #
"fmt"
"sort"
"fmt"
"sort"
An edits is a list of edits that is sortable by start offset, breaking ties by end offset.
type edits []editA Buffer is a queue of edits to apply to a given byte slice.
type Buffer struct {
old []byte
q edits
}An edit records a single text modification: change the bytes in [start,end) to new.
type edit struct {
start int
end int
new string
}Bytes returns a new byte slice containing the original data with the queued edits applied.
func (b *Buffer) Bytes() []bytefunc (b *Buffer) Delete(start int, end int)func (b *Buffer) Insert(pos int, new string)func (x edits) Len() intfunc (x edits) Less(i int, j int) boolNewBuffer returns a new buffer to accumulate changes to an initial data slice. The returned buffer maintains a reference to the data, so the caller must ensure the data is not modified until after the Buffer is done being used.
func NewBuffer(data []byte) *Bufferfunc (b *Buffer) Replace(start int, end int, new string)String returns a string containing the original data with the queued edits applied.
func (b *Buffer) String() stringfunc (x edits) Swap(i int, j int)Generated with Arrow