Documentation
¶
Overview ¶
Package codec provides support for interpreting byte slices as slices of other basic types such as runes, int64's or strings.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
Decoder represents the ability to decode a byte slice into a slice of some other data type.
Example ¶
package main import ( "fmt" "unicode/utf8" "cloudeng.io/algo/codec" ) func main() { decoded := codec.NewDecoder(utf8.DecodeRune).Decode([]byte("日本語")) fmt.Println(len(decoded)) }
Output: 3
type Option ¶
type Option func(*options)
Option represents an option accepted by NewDecoder.
func ResizePercent ¶
ResizePercent requests that the returned slice be reallocated if the ratio of unused to used capacity exceeds the specified percentage. That is, if cap(slice) - len(slice)) / len(slice) exceeds the percentage new underlying storage is allocated and contents copied. The default value for ResizePercent is 100.
func SizePercent ¶
SizePercent requests that the initially allocated slice be 'percent' as large as the original input slice's size in bytes. A percent of 25 will divide the original size by 4 for example.