summaryrefslogtreecommitdiff
path: root/sort.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-27 14:43:21 -0600
committerJeff Carr <[email protected]>2024-12-27 14:43:21 -0600
commitc9c98765d257d5898867512646627f02d2f583be (patch)
tree39ec300fc079f74c615dc0a294a1df055cbba47b /sort.go
parent13d9cfd6586c038aa1d3647f5407c82c9a252238 (diff)
start thinking about redoing the sort functionv0.0.35
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'sort.go')
-rw-r--r--sort.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/sort.go b/sort.go
index acb8325..bc376ed 100644
--- a/sort.go
+++ b/sort.go
@@ -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, "")