lsb

package
v0.0.0-...-4b9bf86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package lsb provides a Lazy String Buffer: efficient, and NOT concurrency safe!

found in `path/path.go` - chapeaux to Rob Pike

Note: I would not mind to see this below "strings" :-)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Friendly

type Friendly interface {
	Index(i int) byte // read a previously appended byte
	Append(c byte)    // extend by adding c at the end
	Unpend()          // undo last Append - Backtracking - track back
	String() string   // the final string - result
	Pos() int         // bytes written
}

Friendly - interface exposed for go doc only

type LazyStringBuffer

type LazyStringBuffer struct {
	// contains filtered or unexported fields
}

LazyStringBuffer is a lazily constructed path buffer. It supports append, reading previously appended bytes, and retrieving the final string. It does not allocate a buffer to hold the output until that output diverges from s.

func New

func New(s string) *LazyStringBuffer

New returns a pointer to a fresh LazyStringBuffer

func (*LazyStringBuffer) Append

func (b *LazyStringBuffer) Append(c byte)

Append appends c to the buffer b

func (*LazyStringBuffer) Index

func (b *LazyStringBuffer) Index(i int) byte

Index returns the byte at i

func (*LazyStringBuffer) Pos

func (b *LazyStringBuffer) Pos() int

Pos returns the position

func (*LazyStringBuffer) String

func (b *LazyStringBuffer) String() string

String returns the content as string

func (*LazyStringBuffer) Unpend

func (b *LazyStringBuffer) Unpend()

Unpend undoes the last Append

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL