-
Notifications
You must be signed in to change notification settings - Fork 0
/
iterable.go
41 lines (31 loc) · 895 Bytes
/
iterable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package goiter
type Iterable struct {
iterator Iterator
}
func NewIterable(iterator Iterator) *Iterable {
return &Iterable{iterator}
}
func (it *Iterable) ForEach(f func(interface{})) {
ForEach(it.iterator, f)
}
func (it *Iterable) Collect() []interface{} {
return Collect(it.iterator)
}
func (it *Iterable) Any(f func(interface{}) bool) bool {
return Any(it.iterator, f)
}
func (it *Iterable) All(f func(interface{}) bool) bool {
return All(it.iterator, f)
}
func (it *Iterable) Map(f func(interface{}) interface{}) *Iterable {
return &Iterable{Map(it.iterator, f)}
}
func (it *Iterable) Filter(f func(interface{}) bool) *Iterable {
return &Iterable{Filter(it.iterator, f)}
}
func (it *Iterable) While(f func(interface{}) bool) *Iterable {
return &Iterable{While(it.iterator, f)}
}
func (it *Iterable) Skip(skip uint) *Iterable {
return &Iterable{Skip(it.iterator, skip)}
}