diff options
| author | Jeff Carr <[email protected]> | 2025-01-12 06:36:11 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-12 06:36:11 -0600 |
| commit | 0600f5448806d120f5f732f2e8076a91ac520c35 (patch) | |
| tree | 27b3f7fbe0d09e7fb444542df101043d7577dd73 /patchset.HAMDMADE.go | |
| parent | 0ea93faef25eda579e3c557b10ff98a766689e40 (diff) | |
remove HANDMADE iterator after fixing autogenpb
Diffstat (limited to 'patchset.HAMDMADE.go')
| -rw-r--r-- | patchset.HAMDMADE.go | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/patchset.HAMDMADE.go b/patchset.HAMDMADE.go deleted file mode 100644 index 5f3124b..0000000 --- a/patchset.HAMDMADE.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. -// This file was autogenerated with autogenpb v0.0.40-19-gfed674d 2025.01.11_0448 -// go install go.wit.com/apps/autogenpb@latest -// -// define which structs (messages) you want to use in the .proto file -// Then sort.pb.go and marshal.pb.go files are autogenerated -// -// autogenpb uses it and has an example .proto file with instructions -// - -package forgepb - -import ( - "fmt" - "sort" - "sync" -) - -// 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 |
