summaryrefslogtreecommitdiff
path: root/sort.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-09 21:15:01 -0600
committerJeff Carr <[email protected]>2025-01-09 21:15:01 -0600
commit02e868647f346074e548cd03f2b52131420d72ec (patch)
tree8e89eccb61e2f9197ca0a867fde7cb77b37c715a /sort.go
parent805d3cdcc3f1cb71c80fa32d42755f2d839f22f5 (diff)
needed DeleteBy()
Diffstat (limited to 'sort.go')
-rw-r--r--sort.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/sort.go b/sort.go
index 6eb5d34..ee5d7a9 100644
--- a/sort.go
+++ b/sort.go
@@ -223,26 +223,26 @@ func iterReplace(w io.Writer, names map[string]string) {
fmt.Fprintln(w, "")
}
-func iterDelete(w io.Writer, names map[string]string) {
- fmt.Fprintln(w, "func (all *"+names["Bases"]+") DeleteBy"+names["append"]+"(s string) bool {")
- if sortmap["lock"] == "all" {
- fmt.Fprintln(w, " "+names["lock"]+".Lock.RLock()")
- fmt.Fprintln(w, " defer "+names["lock"]+".Lock.RUnlock()")
- } else {
- fmt.Fprintln(w, " "+names["lock"]+".RLock()")
- fmt.Fprintln(w, " defer "+names["lock"]+".RUnlock()")
+func (pf *File) iterDelete(w io.Writer) {
+ var MSG string = pf.Bases.Name
+ var LOCK string = pf.Bases.Lockname
+
+ for _, KEY := range pf.Base.Sort {
+ fmt.Fprintln(w, "func (all *"+MSG+") DeleteBy"+KEY+"(s string) bool {")
+ fmt.Fprintln(w, " "+LOCK+".RLock()")
+ fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
+ fmt.Fprintln(w, "")
+ fmt.Fprintln(w, " for i, _ := range all."+MSG+" {")
+ fmt.Fprintln(w, " if all."+MSG+"[i]."+KEY+" == s {")
+ fmt.Fprintln(w, " all."+MSG+"[i] = all."+MSG+"[len(all."+MSG+")-1]")
+ fmt.Fprintln(w, " all."+MSG+" = all."+MSG+"[:len(all."+MSG+")-1]")
+ fmt.Fprintln(w, " return true")
+ fmt.Fprintln(w, " }")
+ fmt.Fprintln(w, " }")
+ fmt.Fprintln(w, " return false")
+ fmt.Fprintln(w, "}")
+ fmt.Fprintln(w, "")
}
- fmt.Fprintln(w, "")
- fmt.Fprintln(w, " for i, _ := range all."+names["Bases"]+" {")
- fmt.Fprintln(w, " if all."+names["Bases"]+"[i]."+names["append"]+" == s {")
- fmt.Fprintln(w, " all."+names["Bases"]+"[i] = all."+names["Bases"]+"[len(all."+names["Bases"]+")-1]")
- fmt.Fprintln(w, " all."+names["Bases"]+" = all."+names["Bases"]+"[:len(all."+names["Bases"]+")-1]")
- fmt.Fprintln(w, " return true")
- fmt.Fprintln(w, " }")
- fmt.Fprintln(w, " }")
- fmt.Fprintln(w, " return false")
- fmt.Fprintln(w, "}")
- fmt.Fprintln(w, "")
}
// this tries to return the deleted one but is wrong/gives warning if mutex lock is in struct