summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-11 06:07:48 -0600
committerJeff Carr <[email protected]>2025-01-11 06:07:48 -0600
commit0b4ab2fb9f860e21a8ca43390fa6a4af4678f29a (patch)
treefd10057d03894b2679fb0ad6bee7187ccdf9feab
parent95afc5e0b47cd4788ade944f87e3452c5d4991c7 (diff)
minorv0.0.41
-rw-r--r--generateHeader.go2
-rw-r--r--patchset.HAMDMADE63
2 files changed, 1 insertions, 64 deletions
diff --git a/generateHeader.go b/generateHeader.go
index 8d5fbfb..99040d2 100644
--- a/generateHeader.go
+++ b/generateHeader.go
@@ -37,7 +37,7 @@ func header(w io.Writer, pf *File) {
fmt.Fprintf(w, "package %s\n", pf.Package)
fmt.Fprintln(w, "")
fmt.Fprintln(w, "import (")
- fmt.Fprintln(w, " \"fmt\"")
+ // fmt.Fprintln(w, " \"fmt\"")
fmt.Fprintln(w, " \"sort\"")
fmt.Fprintln(w, " \"sync\"")
fmt.Fprintln(w, ")")
diff --git a/patchset.HAMDMADE b/patchset.HAMDMADE
deleted file mode 100644
index 62741dc..0000000
--- a/patchset.HAMDMADE
+++ /dev/null
@@ -1,63 +0,0 @@
-// DEFINE THE ITERATOR. Only one per Patch message
-
-// NewPatchsetIterator initializes a new iterator.
-func NewPatchIterator(things []*Patch) *PatchIterator {
- return &PatchIterator{things: things}
-}
-
-// safely returns a slice of pointers to the Patchset protobufs
-func (x *Patchset) all() []*Patch {
- x.Lock.RLock()
- defer x.Lock.RUnlock()
-
- // Create a new slice to hold pointers to each Patchset
- var tmp []*Patch
- tmp = make([]*Patch, len(x.Patches))
- for i, p := range x.Patches {
- tmp[i] = p // Copy pointers for safe iteration
- }
-
- return tmp
-}
-
-type PatchIterator struct {
- sync.RWMutex
-
- things []*Patch
- index int
-}
-
-func (it *PatchIterator) Scan() bool {
- if it.index >= len(it.things) {
- return false
- }
- it.index++
- return true
-}
-
-// Next() returns the next thing in the array
-func (it *PatchIterator) Next() *Patch {
- if it.things[it.index-1] == nil {
- fmt.Println("Next() error in PatchIterator", it.index)
- }
- return it.things[it.index-1]
-}
-
-// END DEFINE THE ITERATOR
-
-// START sort by Filename (this is all you need once the Iterator is defined)
-type PatchFilename []*Patch
-
-func (a PatchFilename) Len() int { return len(a) }
-func (a PatchFilename) Less(i, j int) bool { return a[i].Filename < a[j].Filename }
-func (a PatchFilename) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-
-func (x *Patchset) SortByFilename() *PatchIterator {
- things := x.all()
-
- sort.Sort(PatchFilename(things))
-
- iterator := NewPatchIterator(things)
- return iterator
-}
-// END sort by Filename