console: dynamically fetch available dimensions

This commit is contained in:
Vincent Bernat
2022-05-16 10:11:12 +02:00
parent 42545c9a11
commit 34f153d9cd
10 changed files with 224 additions and 94 deletions

View File

@@ -33,6 +33,24 @@ func (bi *Bimap[K, V]) LoadKey(v V) (K, bool) {
return k, ok
}
// Keys returns a slice of the keys in the bimap.
func (bi *Bimap[K, V]) Keys() []K {
var keys []K
for k := range bi.forward {
keys = append(keys, k)
}
return keys
}
// Values returns a slice of the values in the bimap.
func (bi *Bimap[K, V]) Values() []V {
var values []V
for v := range bi.inverse {
values = append(values, v)
}
return values
}
// String returns a string representation of the bimap.
func (bi *Bimap[K, V]) String() string {
return fmt.Sprintf("Bi%v", bi.forward)