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 []edit
A 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() []byte
func (b *Buffer) Delete(start int, end int)
func (b *Buffer) Insert(pos int, new string)
func (x edits) Len() int
func (x edits) Less(i int, j int) bool
NewBuffer 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) *Buffer
func (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() string
func (x edits) Swap(i int, j int)
Generated with Arrow