func (c *Collection) NewCursor() (*Cursor, error) {
	if atomic.LoadUint32(&c.internalState) != 0 {
		return nil, ErrInternal
	}
	c.metaLock.RLock()
	defer c.metaLock.RUnlock()
	if c.Next[0] == 0 {
		return &Cursor{
			collection: c,
			current:    nil,
			first:      false,
			snapshot:   c.LastCommit,
		}, nil
	}
	head, err := c.readRecord(c.Next[0], false)
	if err != nil {
		return nil, err
	}
	cur := &Cursor{
		collection: c,
		current:    head,
		first:      true,
		snapshot:   c.LastCommit,
	}
	var rec *record
	for (atomic.LoadInt64(&cur.current.Deleted) != 0 && atomic.LoadInt64(&cur.current.Deleted) <= cur.snapshot) ||
		(cur.current.Offset >= cur.snapshot) {
		rec, err = cur.collection.readRecord(atomic.LoadInt64(&cur.current.Next[0]), false)
		if err != nil {
			cur.current = nil
			cur.err = err
			return cur, nil
		}
		cur.current = rec
	}
	return cur, nil
}
NewCursor returns a new cursor with a snapshot view of the
current collection state.
package lm2
import "sync/atomic"
type Cursor struct {
	collection *Collection
	current    *record
	first      bool
	snapshot   int64
	err        error
}