frostfs-node/pkg/innerring/alphabet.go
Dmitrii Stepanov e89fa7f69f [#280] ir: Add alphabet processor unit tests
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-05-02 08:48:07 +00:00

135 lines
2.4 KiB
Go

package innerring
import "github.com/nspcc-dev/neo-go/pkg/util"
type GlagoliticLetter int8
const (
_ GlagoliticLetter = iota - 1
az
buky
vedi
glagoli
dobro
yest
zhivete
dzelo
zemlja
izhe
izhei
gerv
kako
ljudi
mislete
nash
on
pokoj
rtsi
slovo
tverdo
uk
fert
kher
oht
shta
tsi
cherv
sha
yer
yeri
yerj
yat
jo
yu
smallYus
smallIotatedYus
bigYus
bigIotatedYus
fita
izhitsa
lastLetterNum
)
var glagolicLetterToString = map[GlagoliticLetter]string{
az: "az",
buky: "buky",
vedi: "vedi",
glagoli: "glagoli",
dobro: "dobro",
yest: "yest",
zhivete: "zhivete",
dzelo: "dzelo",
zemlja: "zemlja",
izhe: "izhe",
izhei: "izhei",
gerv: "gerv",
kako: "kako",
ljudi: "ljudi",
mislete: "mislete",
nash: "nash",
on: "on",
pokoj: "pokoj",
rtsi: "rtsi",
slovo: "slovo",
tverdo: "tverdo",
uk: "uk",
fert: "fert",
kher: "kher",
oht: "oht",
shta: "shta",
tsi: "tsi",
cherv: "cherv",
sha: "sha",
yer: "yer",
yeri: "yeri",
yerj: "yerj",
yat: "yat",
jo: "jo",
yu: "yu",
smallYus: "small.yus",
smallIotatedYus: "small.iotated.yus",
bigYus: "big.yus",
bigIotatedYus: "big.iotated.yus",
fita: "fita",
izhitsa: "izhitsa",
}
// String returns l in config-compatible format.
func (l GlagoliticLetter) String() string {
if str, found := glagolicLetterToString[l]; found {
return str
}
return "unknown"
}
type AlphabetContracts map[GlagoliticLetter]util.Uint160
func NewAlphabetContracts() AlphabetContracts {
return make(map[GlagoliticLetter]util.Uint160, lastLetterNum)
}
func (a AlphabetContracts) GetByIndex(ind int) (util.Uint160, bool) {
if ind < 0 || ind >= int(lastLetterNum) {
return util.Uint160{}, false
}
contract, ok := a[GlagoliticLetter(ind)]
return contract, ok
}
func (a AlphabetContracts) indexOutOfRange(ind int) bool {
return ind < 0 && ind >= len(a)
}
func (a AlphabetContracts) iterate(f func(GlagoliticLetter, util.Uint160)) {
for letter, contract := range a {
f(letter, contract)
}
}
func (a *AlphabetContracts) set(l GlagoliticLetter, h util.Uint160) {
(*a)[l] = h
}