Documentation
¶
Overview ¶
Example (Index) ¶
for _, i := range [...]int{64, 128, 192, 256, 257} {
fmt.Println(i, "=", index(i))
}
Output: 64 = 0 128 = 1 192 = 2 256 = 2 257 = 3
Example (RoundPow) ¶
for _, i := range [...]int{0, 1, 2, 64, 128, 192, 256, 257} {
fmt.Println(i, "=", roundPow(i))
}
Output: 0 = 1 1 = 1 2 = 2 64 = 64 128 = 128 192 = 256 256 = 256 257 = 512
Index ¶
- Variables
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) Grow(n int) error
- func (b *Buffer) Len() int
- func (b *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Write(p []byte) (n int, err error)
- func (b *Buffer) WriteByte(c byte) error
- func (b *Buffer) WriteString(s string) (n int, err error)
- func (b *Buffer) WriteTo(w io.Writer) (int64, error)
- type Pool
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNegativeCount = errors.New("negative count")
)
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
B []byte
}
A byte buffer, highly optimized to minimize allocations and GC pressure.
func (*Buffer) Grow ¶
Grow grows b's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to b without another allocation. If n is negative, Grow panics.
func (*Buffer) WriteString ¶
WriteString implements io.StringWriter.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool represents byte buffer pool.
Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.
Click to show internal directories.
Click to hide internal directories.