mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-28 00:53:45 +08:00
ab81464bd1
Add navigation and map matching providers with the vendored map service sources. Co-authored-by: Daniel Koepping <elkoled@gmail.com> Co-authored-by: Danny <dannyirwin31@yahoo.com> Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
39 lines
641 B
Go
39 lines
641 B
Go
package utils
|
|
|
|
type CurryList[T any] struct {
|
|
getter func(int) T
|
|
set []bool
|
|
val []T
|
|
}
|
|
|
|
func (c *CurryList[T]) At(index int) T {
|
|
if c.set[index] {
|
|
return c.val[index]
|
|
}
|
|
c.Set(c.getter(index), index)
|
|
return c.val[index]
|
|
}
|
|
|
|
func (c *CurryList[T]) Set(val T, index int) {
|
|
c.set[index] = true
|
|
c.val[index] = val
|
|
}
|
|
|
|
func (c *CurryList[T]) Len() int {
|
|
return len(c.val)
|
|
}
|
|
|
|
func (c *CurryList[T]) Init(getter func(int) T, length int) {
|
|
c.getter = getter
|
|
c.set = make([]bool, length)
|
|
c.val = make([]T, length)
|
|
}
|
|
|
|
func (c *CurryList[T]) Slice() []T {
|
|
res := make([]T, c.Len())
|
|
for i := range res {
|
|
res[i] = c.At(i)
|
|
}
|
|
return res
|
|
}
|