Documentation ¶
Index ¶
- func Abs(x int) int
- func After(value string, a string) string
- func AfterSpace(value string) string
- func Before(value string, a string) string
- func BeforeSpace(value string) string
- func ContainsInt(lst []int, x int) bool
- func CountLines(filename string) (int, error)
- func DeserializeFromFile(filename string, obj Deserializer) (err error)
- func ForEachField(i interface{}, ...)
- func GetNeighborsIndices(size, index, windowSize int) []int
- func IsStruct(i interface{}) bool
- func MakeIndices(size int) []int
- func MakeIntMatrix(rows, cols int) [][]int
- func MinInt(a, b int) int
- func Name(i interface{}) string
- func ReadFull(r io.Reader, buf []byte) (int, error)
- func ReverseInPlace(s interface{})
- func ReverseIntSlice(lst []int) []int
- func ReverseString(text string) string
- func SerializeToFile(filename string, obj Serializer) (err error)
- func SplitByRune(str string) []string
- func SumInt(v []int) (s int)
- func TypeName(instance interface{}) string
- type Deserializer
- type Pool
- type Serializer
- type Slice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterSpace ¶
AfterSpace returns the substring from value which comes after the first whitespace.
func BeforeSpace ¶
BeforeSpace returns the substring from value which comes before the first whitespace.
func ContainsInt ¶
ContainsInt returns whether the list contains the x-element, or not.
func CountLines ¶
CountLines efficiently counts the lines of text inside a file. See: https://stackoverflow.com/questions/24562942/golang-how-do-i-determine-the-number-of-lines-in-a-file-efficiently
func DeserializeFromFile ¶
func DeserializeFromFile(filename string, obj Deserializer) (err error)
DeserializeFromFile deserializes obj from file.
func ForEachField ¶
func ForEachField(i interface{}, callback func(field interface{}, name string, tag reflect.StructTag))
ForEachField calls the callback for each field of the struct i.
func GetNeighborsIndices ¶
GetNeighborsIndices returns the indices of the (circular) neighbours at position index.
func MakeIndices ¶
MakeIndices returns a slice of the given size, where each element has the same value of its own index position.
func MakeIntMatrix ¶
MakeIntMatrix returns a new 2-dimensional slice of int.
func ReadFull ¶
ReadFull reads from r into buf until it has read len(buf). It returns the number of bytes copied and an error if fewer bytes were read. If an EOF happens after reading fewer than len(buf) bytes, io.ErrUnexpectedEOF is returned.
func ReverseInPlace ¶
func ReverseInPlace(s interface{})
ReverseInPlace reverses the elements of s (usually a slice).
func ReverseIntSlice ¶
ReverseIntSlice returns a reversed version of the given slice.
func ReverseString ¶
ReverseString reverses the given string.
func SerializeToFile ¶
func SerializeToFile(filename string, obj Serializer) (err error)
SerializeToFile serializes obj to file.
func SplitByRune ¶
SplitByRune splits the input string by runes, and produces a new slice of string, where each item is one rune converted to string.
Types ¶
type Deserializer ¶
Deserializer is implemented by any value that has the Deserialize method.
type Pool ¶
type Pool struct { // New optionally specifies a function to generate // a value when Get would otherwise return nil. New func() interface{} // contains filtered or unexported fields }
Pool is a naive implementation of a pool, based on broadcast channel. You can use this pool in the same way you use sync.Pool.
func NewPool ¶
NewPool returns a new pool ready to use. The pool can contain up to a max number of items. Set the property New to generate new items when needed during the Get.
type Serializer ¶
Serializer is implemented by any value that has the Serialize method.
type Slice ¶
Slice is an extension of sort.Interface which keeps track of the original indices of the elements of a slice after sorting.
func NewFloat64Slice ¶
NewFloat64Slice returns a new Slice for the given sequence of float64 values.
func NewIntSlice ¶
NewIntSlice returns a new Slice for the given sequence of int values.
func NewStringSlice ¶
NewStringSlice returns a new Slice for the given sequence of string values.