func (f FakeStore) EntriesByOwner( t db.Transaction, owner int64, consumer functional.Consumer) error { s := functional.NewStreamFromPtrs(f, nil) s = functional.Filter(functional.NewFilterer(func(ptr interface{}) error { p := ptr.(*vsafe.Entry) if p.Owner == owner { return nil } return functional.Skipped }), s) return consumer.Consume(s) }
func ExampleNewGenerator() { s := functional.NewStreamFromPtrs( []*DateCount{ {YMD(2013, 5, 24), 13}, {YMD(2013, 4, 1), 5}, {YMD(2013, 1, 1), 8}, {YMD(2012, 12, 31), 24}, {YMD(2012, 5, 26), 10}}, nil) s = ByYear(s) defer s.Close() var yc YearCount for err := s.Next(&yc); err == nil; err = s.Next(&yc) { fmt.Printf("%d: %d\n", yc.Year, yc.Count) } // Output: // 2013: 26 // 2012: 34 }