Notes added by 'git notes append'

This commit is contained in:
Jeff Carr 2025-02-14 00:46:58 -06:00
parent 9e0b11d081
commit 92af42dc3a
1 changed files with 414 additions and 0 deletions

View File

@ -726,3 +726,417 @@ func file_table_proto_init() {
}
// `autogen:table.sort.pb.go`
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.0.52-1-g4fdcc99 2025.02.12_1512
// 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 guipb
import (
"fmt"
"sync"
)
// a simple global lock
var tableMu sync.RWMutex
func (x *Tables) fixUuid() {
if x == nil {
return
}
if x.Uuid == "c328aa62-3c4f-4d00-9244-cc44ae75ab1b" {
return
}
x.Uuid = "c328aa62-3c4f-4d00-9244-cc44ae75ab1b"
x.Version = "v1 go.wit.com/lib/protobuf/guipb"
}
func NewTables() *Tables {
x := new(Tables)
x.Uuid = "c328aa62-3c4f-4d00-9244-cc44ae75ab1b"
x.Version = "v1 go.wit.com/lib/protobuf/guipb"
return x
}
// START SORT
// DEFINE THE Tables ITERATOR.
// itializes a new iterator.
func newTablesIterator(things []*Tables) *TablesIterator {
return &TablesIterator{things: things}
}
type TablesIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*Tables
index int
}
func (it *TablesIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *TablesIterator) Next() *Tables {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in TablesIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE Table ITERATOR.
// itializes a new iterator.
func newTableIterator(things []*Table) *TableIterator {
return &TableIterator{things: things}
}
type TableIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*Table
index int
}
func (it *TableIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *TableIterator) Next() *Table {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in TableIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE StringRow ITERATOR.
// itializes a new iterator.
func newStringRowIterator(things []*StringRow) *StringRowIterator {
return &StringRowIterator{things: things}
}
type StringRowIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*StringRow
index int
}
func (it *StringRowIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *StringRowIterator) Next() *StringRow {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in StringRowIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE IntRow ITERATOR.
// itializes a new iterator.
func newIntRowIterator(things []*IntRow) *IntRowIterator {
return &IntRowIterator{things: things}
}
type IntRowIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*IntRow
index int
}
func (it *IntRowIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *IntRowIterator) Next() *IntRow {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in IntRowIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE TimeRow ITERATOR.
// itializes a new iterator.
func newTimeRowIterator(things []*TimeRow) *TimeRowIterator {
return &TimeRowIterator{things: things}
}
type TimeRowIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*TimeRow
index int
}
func (it *TimeRowIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *TimeRowIterator) Next() *TimeRow {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in TimeRowIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE BoolRow ITERATOR.
// itializes a new iterator.
func newBoolRowIterator(things []*BoolRow) *BoolRowIterator {
return &BoolRowIterator{things: things}
}
type BoolRowIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*BoolRow
index int
}
func (it *BoolRowIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *BoolRowIterator) Next() *BoolRow {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in BoolRowIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// safely returns a slice of pointers to the FRUIT protobufs
func (x *Tables) allTables() []*Table {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*Table
tmp = make([]*Table, len(x.Tables))
for i, p := range x.Tables {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *Table) allStringRows() []*StringRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*StringRow
tmp = make([]*StringRow, len(x.StringRows))
for i, p := range x.StringRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *Table) allIntRows() []*IntRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*IntRow
tmp = make([]*IntRow, len(x.IntRows))
for i, p := range x.IntRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *Table) allTimeRows() []*TimeRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*TimeRow
tmp = make([]*TimeRow, len(x.TimeRows))
for i, p := range x.TimeRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *Table) allBoolRows() []*BoolRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*BoolRow
tmp = make([]*BoolRow, len(x.BoolRows))
for i, p := range x.BoolRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the Table protobufs
func (x *Tables) selectAllTables() []*Table {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each Table
var tmp []*Table
tmp = make([]*Table, len(x.Tables))
for i, p := range x.Tables {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the StringRow protobufs
func (x *Table) selectAllStringRows() []*StringRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each StringRow
var tmp []*StringRow
tmp = make([]*StringRow, len(x.StringRows))
for i, p := range x.StringRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the IntRow protobufs
func (x *Table) selectAllIntRows() []*IntRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each IntRow
var tmp []*IntRow
tmp = make([]*IntRow, len(x.IntRows))
for i, p := range x.IntRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the TimeRow protobufs
func (x *Table) selectAllTimeRows() []*TimeRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each TimeRow
var tmp []*TimeRow
tmp = make([]*TimeRow, len(x.TimeRows))
for i, p := range x.TimeRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the BoolRow protobufs
func (x *Table) selectAllBoolRows() []*BoolRow {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each BoolRow
var tmp []*BoolRow
tmp = make([]*BoolRow, len(x.BoolRows))
for i, p := range x.BoolRows {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// END SORT
func (x *Tables) Len() int {
x.RLock()
defer x.RUnlock()
return len(x.Tables)
}
// just a simple Append() shortcut (but still uses the mutex lock)
func (x *Tables) Append(y *Table) {
x.Lock()
defer x.Unlock()
x.Tables = append(x.Tables, y)
}
func (x *Tables) All() *TableIterator {
TablePointers := x.selectAllTables()
iterator := newTableIterator(TablePointers)
return iterator
}
func (x *Tables) Delete(y *Table) bool {
x.Lock()
defer x.Unlock()
for i, _ := range x.Tables {
if x.Tables[i] == y {
x.Tables[i] = x.Tables[len(x.Tables)-1]
x.Tables = x.Tables[:len(x.Tables)-1]
return true
}
}
return false
}