Documentation
¶
Index ¶
- func Append(container, value interface{})
- func BlockClear(container interface{}, d, n int)
- func BlockCopy(container interface{}, d, s, n int)
- func BlockSwap(container interface{}, d, s, n int)
- func Cap(container interface{}) (l int)
- func Collect(container interface{}, f interface{}) (r interface{}, ok bool)
- func Combine(left, right interface{}, f func(interface{}, interface{}) interface{}) (r interface{})
- func Count(container interface{}, f func(interface{}) bool) (n int)
- func Cycle(container interface{}, count int, f func(interface{})) (i int, ok bool)
- func Dense(container interface{}, d, t float64, f func(interface{}) bool) bool
- func Density(container interface{}, f func(interface{}) bool) (r float64)
- func Depth(container interface{}) (d int)
- func Each(container, f interface{}) (ok bool)
- func Equal(x, y interface{}) bool
- func Feed(container interface{}, c chan interface{}, f func(x interface{}) interface{})
- func First(container interface{}, i int) interface{}
- func Flatten(container interface{})
- func Last(container interface{}, i int) interface{}
- func Len(container interface{}) (l int)
- func Most(container interface{}, t float64, f func(interface{}) bool) bool
- func One(container interface{}, f func(interface{}) bool) (b bool)
- func Overwrite(destination interface{}, offset int, source interface{})
- func Pipe(container interface{}, f func(x interface{}) interface{}) (c chan interface{})
- func Reallocate(container interface{}, length, capacity int) (r interface{})
- func Reduce(container, seed interface{}, f interface{}) (r interface{}, ok bool)
- func Repeat(container interface{}, count int)
- func Resize(container interface{}, x, n int) (r interface{})
- func Reverse(container interface{})
- func Subslice(container interface{}, start, end int) (r interface{})
- func Transform(container, t interface{}) (ok bool)
- func Until(container, f interface{}) (count int)
- func WaitFor(f func())
- func While(container, f interface{}) (count int)
- type Appendable
- type Blitter
- type Collectable
- type Combinable
- type Deque
- type Equatable
- type Feeder
- type FixedSize
- type Flattenable
- type Indexable
- type IndexedReader
- type IndexedWriter
- type Iterable
- type Linear
- type Linkable
- type Mappable
- type MappedReader
- type MappedWriter
- type Nested
- type Overwriteable
- type PartiallyIterable
- type Piper
- type Reducible
- type Repeatable
- type Resizeable
- type Reversible
- type Sliceable
- type Transformable
- type Typed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlockClear ¶
func BlockClear(container interface{}, d, n int)
func Combine ¶
func Combine(left, right interface{}, f func(interface{}, interface{}) interface{}) (r interface{})
Combine takes two parameters and applies a function to them. In the case of scalar parameters the function is applied once and the result returned. In the case of vector parameters the function is applied to each matched pair of elements and the result returned. A vector result will always have the same type as the left-hand parameter and the number of elements in the result vector will be the same as the number of elements in the lef-hand parameter with trailing unmatched values combined with the correct zero value for the contained type.
func Depth ¶
func Depth(container interface{}) (d int)
Calculate the depth of nesting of a container. A scalar value and an empty container will both return a depth of zero. All other containers will return a depth of 1+.
func One ¶
While processes values from a container whilst a condition is true or until the end of the container is reached. Returns the count of items which pass the test.
func While(container interface{}, f func(interface{}) bool) (i int) {
jittery.Catch(func() {
Each(container, func(x interface{}) {
if f(x) {
i++
} else {
jittery.Throw()
}
})
})
return
}
// Until processes values from a container until a condition is true or until the end of the container is reached. // Returns the count of items which fail the test.
func Until(container interface{}, f func(interface{}) bool) (i int) {
jittery.Catch(func() {
Each(container, func(x interface{}) {
if f(x) {
jittery.Throw()
} else {
i++
}
})
})
return
}
func Any(container interface{}, f func(interface{}) bool) (b bool) {
if l := Until(container, f); l > 0 {
b = l < Len(container)
}
return
}
func All(container interface{}, f func(interface{}) bool) (b bool) {
if l := While(container, f); l > 0 {
b = l == Len(container)
}
return
}
func None(container interface{}, f func(interface{}) bool) (b bool) {
return Until(container, f) == Len(container)
}
func Pipe ¶
func Pipe(container interface{}, f func(x interface{}) interface{}) (c chan interface{})
func Reallocate ¶
func Reallocate(container interface{}, length, capacity int) (r interface{})
Create a new memory container and copy contents across to it. Returns nil when reallocation fails.
Types ¶
type Appendable ¶
type Appendable interface {
Append(interface{})
}
type Collectable ¶
type Collectable interface {
Collect(f interface{}) (r interface{}, ok bool)
}
type Combinable ¶
type Combinable interface {
Combine(interface{}, func(interface{}, interface{}) interface{}) interface{}
}
type Deque ¶
type Deque interface {
PopFirst() interface{}
PopLast() interface{}
Append(i interface{})
Prepend(i interface{})
}
type Flattenable ¶
type Flattenable interface {
Flatten()
}
type Indexable ¶
type Indexable interface {
IndexedReader
IndexedWriter
}
type IndexedReader ¶
type IndexedWriter ¶
type Mappable ¶
type Mappable interface {
Linear
MappedReader
MappedWriter
}
type MappedReader ¶
type MappedReader interface {
At(key interface{}) interface{}
Keys() []interface{}
}
type MappedWriter ¶
type MappedWriter interface {
Set(key interface{}, value interface{})
Clear(key interface{})
}
type Overwriteable ¶
type Overwriteable interface {
Overwrite(offset interface{}, container interface{})
}
type PartiallyIterable ¶
type Reducible ¶
type Reducible interface {
Reduce(seed, function interface{}) (r interface{}, ok bool)
}
type Repeatable ¶
type Repeatable interface {
Repeat(count int)
}
type Resizeable ¶
type Reversible ¶
type Reversible interface {
Reverse()
}
type Transformable ¶
type Transformable interface {
Transform(interface{}) bool
}