summaryrefslogtreecommitdiff
path: root/src/nslcd_proto/enumerator@T.got
blob: 5a540ae8adf649829b65aebdfa72e219914adb26 (plain)
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
42
// -*- Mode: Go -*-
package nslcd_proto

type <T>_Enumerator interface {
	GetNext() (n *<T>, err error)
	GenericGetNext() (n interface{}, err error)
}

type <T>_List struct {
	dat []<T>
	i   int
}

var _ <T>_Enumerator = &<T>_List{}

func New_<T>_List(ary []<T>) *<T>_List {
	return &<T>_List{ary, 0}
}

func (o *<T>_List) GetNext() (n *<T>, err error) {
	if o.i < len(o.dat) {
		n = &o.dat[o.i]
		o.i++
	}
	err = nil
	return
}

func (o *<T>_List) GenericGetNext() (n interface{}, err error) {
	return o.GetNext()
}

type <T>_Ø struct{}

var _ <T>_Enumerator = <T>_Ø{}

func (o <T>_Ø) GetNext() (*<T>, error) {
	return nil, nil
}
func (o <T>_Ø) GenericGetNext() (interface{}, error) {
	return nil, nil
}