10 examples of 'golang iterator' in Go

Every line of 'golang iterator' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
126func (pi *prefixIterable) Iterator(low, high []byte) (KVIterator, error) {
127 return pi.prefix.Iterator(pi.source.Iterator, low, high)
128}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

197func (btc *bTreeContainers) Iterator(key uint64) (citer ContainerIterator, found bool) {
198 e, ok := btc.tree.Seek(key)
199 if ok {
200 found = true
201 }
202
203 return &btcIterator{
204 e: e,
205 }, found
206}
117func (c *XORChunk) iterator(it Iterator) *xorIterator {
118 // Should iterators guarantee to act on a copy of the data so it doesn't lock append?
119 // When using striped locks to guard access to chunks, probably yes.
120 // Could only copy data if the chunk is not completed yet.
121 if xorIter, ok := it.(*xorIterator); ok {
122 xorIter.Reset(c.b.bytes())
123 return xorIter
124 }
125 return &xorIterator{
126 // The first 2 bytes contain chunk headers.
127 // We skip that for actual samples.
128 br: newBReader(c.b.bytes()[2:]),
129 numTotal: binary.BigEndian.Uint16(c.b.bytes()),
130 t: math.MinInt64,
131 }
132}
227func (i *concatIterable) Iterator() Iterator {
228 return &concatIterator{i.a.Iterator(), i.b.Iterator(), defaultElementValue}
229}
360func (block *trieTreeBlock) Iterator(prefixValue string) *TrieTreeIterator {
361 return &TrieTreeIterator{
362 block: block,
363 prefixValue: []byte(prefixValue)}
364}
82func (tkv *Store) Iterator(start, end []byte) (types.Iterator, error) {
83 return tkv.iterator(start, end, true)
84}
83func (tkv *Store) Iterator(start, end []byte) types.Iterator {
84 return tkv.iterator(start, end, true)
85}
63func (t *table) Iterator() Iterator {
64 return t.db.Iterator(t.keyWithPrefix(""))
65}
42func (s *set) Iterator() Iterator {
43 // TODO optimize this, it's horrible...
44 return MakeIterable(func() Generate {
45 var items = make([]interface{}, 0, s.Len())
46 for k, _ := range s.items {
47 items = append(items, k)
48 }
49 iter := items[:]
50 version := s.version
51 return func() (interface{}, bool) {
52 if s.version != version {
53 panic("Concurrent modification detected")
54 }
55 if len(iter) == 0 {
56 return defaultElementValue, false
57 }
58
59 item := iter[0]
60 iter = iter[1:]
61 return item, true
62 }
63 }).Iterator()
64}
114func (db *GoMemDB) Iterator(start []byte, end []byte, reverse bool) Iterator {
115 if end == nil {
116 end = bytesPrefix(start)
117 }
118 if bytes.Equal(end, types.EmptyValue) {
119 end = nil
120 }
121 r := &util.Range{Start: start, Limit: end}
122 it := db.db.NewIterator(r)
123 base := itBase{start, end, reverse}
124 return &goLevelDBIt{it, base}
125}

Related snippets