good morning!!!!

Skip to content
Snippets Groups Projects
Commit b13a35b4 authored by Garet Halliday's avatar Garet Halliday
Browse files

a work of art

parent 585d7cbe
No related branches found
No related tags found
No related merge requests found
......@@ -6,71 +6,84 @@ type {{template "generictypedef" $curCount}} struct {
inner Map1[K0, {{template "reltypedef" (list (sub $curCount 1) 1)}}]
}
func (m *{{template "typedef" $curCount}}) Load(key K0) (value {{template "reltypedef" (list (sub $curCount 1) 1)}}, ok bool) {
return m.inner.Load(key)
func (m *{{template "typedef" $curCount}}) Load({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}} K{{$val}}, {{end}}
) (value V, ok bool) {
return m.Load{{$curCount}}({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}}, {{end}}
)
}
func (m *{{template "typedef" $curCount}}) Delete(key K0) {
m.inner.Delete(key)
func (m *{{template "typedef" $curCount}}) Delete({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}} K{{$val}}, {{end}}
) {
m.Delete{{$curCount}}({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}}, {{end}}
)
}
func (m *{{template "typedef" $curCount}}) Range(f func(K0, {{template "reltypedef" (list (sub $curCount 1) 1)}}) bool) {
m.inner.Range(f)
func (m *{{template "typedef" $curCount}}) Range({{range $val := (iterateFromN 0 $curCount) }}k{{$val}} K{{$val}}, {{end}}
f func(K{{$curCount}}, V) bool) {
m.Range{{$curCount}}({{range $val := (iterateFromN 0 $curCount) }}k{{$val}}, {{end}}f)
}
func (m *{{template "typedef" $curCount}}) LoadAndDelete(key K0) (value {{template "reltypedef" (list (sub $curCount 1) 1)}}, loaded bool) {
return m.inner.LoadAndDelete(key)
func (m *{{template "typedef" $curCount}}) LoadAndDelete({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}} K{{$val}}, {{end}}
) (value V, loaded bool) {
return m.LoadAndDelete{{$curCount}}({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}}, {{end}}
)
}
func (m *{{template "typedef" $curCount}}) LoadOrStore(key K0, v {{template "reltypedef" (list (sub $curCount 1) 1)}}) (value {{template "reltypedef" (list (sub $curCount 1) 1)}}, loaded bool) {
return m.inner.LoadOrStore(key, v)
func (m *{{template "typedef" $curCount}}) LoadOrStore({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}} K{{$val}}, {{end}}
v V) (value V, loaded bool) {
return m.LoadOrStore{{$curCount}}({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}}, {{end}}
v)
}
func (m *{{template "typedef" $curCount}}) Store(key K0, value {{template "reltypedef" (list (sub $curCount 1) 1)}}) {
m.inner.Store(key, value)
func (m *{{template "typedef" $curCount}}) Store({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}} K{{$val}}, {{end}}
value V) {
m.Store{{$curCount}}({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}}, {{end}}
value)
}
{{range $subCurCount:= iterateFromN 1 $curCount}}
{{range $subCurCount:= iterateFromN 0 (add $curCount 1)}}
func (m *{{template "typedef" $curCount}}) Load{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}, ok bool) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, ok = item{{sub $val 1}}.Load(k{{sub $val 1}})
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
}
{{end}}
return item{{$subCurCount}}.Load(k{{$subCurCount}})
return item{{$subCurCount}}.Load0(k{{$subCurCount}})
}
func (m *{{template "typedef" $curCount}}) Delete{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
) {
var ok bool
_ = ok
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, ok = item{{sub $val 1}}.Load(k{{sub $val 1}})
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
}
{{end}}
item{{$subCurCount}}.Delete(k{{$subCurCount}})
item{{$subCurCount}}.Delete0(k{{$subCurCount}})
}
func (m *{{template "typedef" $curCount}}) Range{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
func (m *{{template "typedef" $curCount}}) Range{{$subCurCount}}({{range $val := (iterateFromN 0 $subCurCount) }}k{{$val}} K{{$val}}, {{end}}
f func(K{{$subCurCount}}, {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}) bool) {
var ok bool
_ = ok
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, ok = item{{sub $val 1}}.Load(k{{sub $val 1}})
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
}
{{end}}
item{{$subCurCount}}.Range(f)
item{{$subCurCount}}.Range0(f)
}
func (m *{{template "typedef" $curCount}}) LoadAndDelete{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
......@@ -78,12 +91,12 @@ func (m *{{template "typedef" $curCount}}) LoadAndDelete{{$subCurCount}}({{range
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, loaded = item{{sub $val 1}}.Load(k{{sub $val 1}})
item{{$val}}, loaded = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !loaded {
return
}
{{end}}
return item{{$subCurCount}}.LoadAndDelete(k{{$subCurCount}})
return item{{$subCurCount}}.LoadAndDelete0(k{{$subCurCount}})
}
func (m *{{template "typedef" $curCount}}) LoadOrStore{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
......@@ -91,9 +104,9 @@ v {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCu
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
{{end}}
return item{{$subCurCount}}.LoadOrStore(k{{$subCurCount}}, v)
return item{{$subCurCount}}.LoadOrStore0(k{{$subCurCount}}, v)
}
func (m *{{template "typedef" $curCount}}) Store{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
......@@ -101,9 +114,9 @@ value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $s
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
{{end}}
item{{$subCurCount}}.Store(k{{$subCurCount}}, value)
item{{$subCurCount}}.Store0(k{{$subCurCount}}, value)
}
{{end}}
......
This diff is collapsed.
......@@ -18,6 +18,10 @@ func (m *Map1[K, V]) Delete(key K) {
m.inner.Delete(key)
}
func (m *Map1[K, V]) Delete0(key K) {
m.Delete(key)
}
// Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (m *Map1[K, V]) Load(key K) (value V, ok bool) {
val, ok := m.inner.Load(key)
......@@ -28,6 +32,10 @@ func (m *Map1[K, V]) Load(key K) (value V, ok bool) {
return def, ok
}
func (m *Map1[K, V]) Load0(key K) (value V, ok bool) {
return m.Load(key)
}
// LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (m *Map1[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
val, loaded := m.inner.LoadAndDelete(key)
......@@ -38,6 +46,10 @@ func (m *Map1[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
return def, loaded
}
func (m *Map1[K, V]) LoadAndDelete0(key K) (value V, loaded bool) {
return m.LoadAndDelete(key)
}
// LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (m *Map1[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
val, loaded := m.inner.LoadOrStore(key, value)
......@@ -48,6 +60,10 @@ func (m *Map1[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
return def, loaded
}
func (m *Map1[K, V]) LoadOrStore0(key K, value V) (actual V, loaded bool) {
return m.LoadOrStore(key, value)
}
// Range calls f sequentially for each key and value present in the map.
// If f returns false, range stops the iteration.
//
......@@ -67,7 +83,15 @@ func (m *Map1[K, V]) Range(f func(key K, value V) bool) {
m.inner.Range(innerFun)
}
func (m *Map1[K, V]) Range0(f func(key K, value V) bool) {
m.Range(f)
}
// Store sets the value for a key.
func (m *Map1[K, V]) Store(key K, value V) {
m.inner.Store(key, value)
}
func (m *Map1[K, V]) Store0(key K, value V) {
m.Store(key, value)
}
......@@ -16,6 +16,10 @@ func (m *Map1[K, V]) Delete(key K) {
m.inner.Delete(key)
}
func (m *Map1[K, V]) Delete0(key K) {
m.Delete(key)
}
// Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (m *Map1[K, V]) Load(key K) (value V, ok bool) {
val, ok := m.inner.Load(key)
......@@ -26,6 +30,10 @@ func (m *Map1[K, V]) Load(key K) (value V, ok bool) {
return def, ok
}
func (m *Map1[K, V]) Load0(key K) (value V, ok bool) {
return m.Load(key)
}
// LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (m *Map1[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
val, loaded := m.inner.LoadAndDelete(key)
......@@ -36,6 +44,10 @@ func (m *Map1[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
return def, loaded
}
func (m *Map1[K, V]) LoadAndDelete0(key K) (value V, loaded bool) {
return m.LoadAndDelete(key)
}
// LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (m *Map1[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
val, loaded := m.inner.LoadOrStore(key, value)
......@@ -46,6 +58,10 @@ func (m *Map1[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
return def, loaded
}
func (m *Map1[K, V]) LoadOrStore0(key K, value V) (actual V, loaded bool) {
return m.LoadOrStore(key, value)
}
// Range calls f sequentially for each key and value present in the map.
// If f returns false, range stops the iteration.
//
......@@ -65,7 +81,15 @@ func (m *Map1[K, V]) Range(f func(key K, value V) bool) {
m.inner.Range(innerFun)
}
func (m *Map1[K, V]) Range0(f func(key K, value V) bool) {
m.Range(f)
}
// Store sets the value for a key.
func (m *Map1[K, V]) Store(key K, value V) {
m.inner.Store(key, value)
}
func (m *Map1[K, V]) Store0(key K, value V) {
m.Store(key, value)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment