jldb/mdb/collection-internal.go

25 lines
546 B
Go
Raw Permalink Normal View History

2023-10-13 09:43:27 +00:00
package mdb
type collectionState[T any] struct {
Version uint64
Indices []indexState[T]
}
func (c *collectionState[T]) clone(version uint64) *collectionState[T] {
indices := make([]indexState[T], len(c.Indices))
for i := range indices {
indices[i] = c.Indices[i].clone()
}
return &collectionState[T]{
Version: version,
Indices: indices,
}
}
// Add an index returning it's assigned ID.
func (c *collectionState[T]) addIndex(idx indexState[T]) uint64 {
id := uint64(len(c.Indices))
c.Indices = append(c.Indices, idx)
return id
}