diff options
Diffstat (limited to 'sort.go')
| -rw-r--r-- | sort.go | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -71,16 +71,16 @@ func iterTop(w io.Writer, names map[string]string) { fmt.Fprintln(w, "type "+names["Base"]+"Iterator struct {") fmt.Fprintln(w, " sync.RWMutex") fmt.Fprintln(w, "") - fmt.Fprintln(w, " packs []*"+names["Base"]) + fmt.Fprintln(w, " things []*"+names["Base"]) fmt.Fprintln(w, " index int") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") fmt.Fprintln(w, "// New"+names["Base"]+"Iterator initializes a new iterator.") - fmt.Fprintln(w, "func New"+names["Base"]+"Iterator(packs []*"+names["Base"]+") *"+names["Base"]+"Iterator {") - fmt.Fprintln(w, " return &"+names["Base"]+"Iterator{packs: packs}") + fmt.Fprintln(w, "func New"+names["Base"]+"Iterator(things []*"+names["Base"]+") *"+names["Base"]+"Iterator {") + fmt.Fprintln(w, " return &"+names["Base"]+"Iterator{things: things}") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") - fmt.Fprintln(w, "// Scan moves to the next element and returns false if there are no more packs.") + fmt.Fprintln(w, "// Scan moves to the next element and returns false if there are no more things.") fmt.Fprintln(w, "// Use Scan() in a loop, similar to a while loop") fmt.Fprintln(w, "//") fmt.Fprintln(w, "// for iterator.Scan() ") @@ -88,7 +88,7 @@ func iterTop(w io.Writer, names map[string]string) { fmt.Fprintln(w, "// fmt.Println(\"found UUID:\", d.Uuid") fmt.Fprintln(w, "// }") fmt.Fprintln(w, "func (it *"+names["Base"]+"Iterator) Scan() bool {") - fmt.Fprintln(w, " if it.index >= len(it.packs) {") + fmt.Fprintln(w, " if it.index >= len(it.things) {") fmt.Fprintln(w, " return false") fmt.Fprintln(w, " }") fmt.Fprintln(w, " it.index++") @@ -100,14 +100,14 @@ func iterTop(w io.Writer, names map[string]string) { func iterNext(w io.Writer, names map[string]string) { fmt.Fprintln(w, "// Next() returns the next thing in the array") fmt.Fprintln(w, "func (it *"+names["Base"]+"Iterator) Next() *"+names["Base"]+" {") - fmt.Fprintln(w, " if it.packs[it.index-1] == nil {") - fmt.Fprintln(w, " for i, d := range it.packs {") + fmt.Fprintln(w, " if it.things[it.index-1] == nil {") + fmt.Fprintln(w, " for i, d := range it.things {") fmt.Fprintln(w, " fmt.Println(\"i =\", i, d)") fmt.Fprintln(w, " }") - fmt.Fprintln(w, " // fmt.Println(\"protobuf autogenpb sort error len =\", len(it.packs))") + fmt.Fprintln(w, " // fmt.Println(\"protobuf autogenpb sort error len =\", len(it.things))") fmt.Fprintln(w, " // fmt.Println(\"protobuf autogenpb sort error next == nil\", it.index, it.index-1)") fmt.Fprintln(w, " }") - fmt.Fprintln(w, " return it.packs[it.index-1]") + fmt.Fprintln(w, " return it.things[it.index-1]") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") } @@ -136,11 +136,11 @@ func iterSortAll(w io.Writer, names map[string]string) { func iterSortBy(w io.Writer, names map[string]string) { fmt.Fprintln(w, "func (all *"+names["Bases"]+") SortBy"+names["sortBy"]+"() *"+names["Base"]+"Iterator {") - fmt.Fprintln(w, " packs := all.selectAll"+names["Base"]+"()") + fmt.Fprintln(w, " things := all.selectAll"+names["Base"]+"()") fmt.Fprintln(w, "") - fmt.Fprintln(w, " sort.Sort("+names["Base"]+""+names["sortBy"]+"(packs))") + fmt.Fprintln(w, " sort.Sort("+names["Base"]+""+names["sortBy"]+"(things))") fmt.Fprintln(w, "") - fmt.Fprintln(w, " iterator := New"+names["Base"]+"Iterator(packs)") + fmt.Fprintln(w, " iterator := New"+names["Base"]+"Iterator(things)") fmt.Fprintln(w, " return iterator") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") |
