dictionary

package
v0.0.0-...-afed897 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2015 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dictionary

type Dictionary struct {
	// contains filtered or unexported fields
}

名称翻译词典 负责在名称和整数ID之间互相翻译 注意名称不能为空,ID从1开始

func NewDictionary

func NewDictionary(minId int) *Dictionary

新建词典 必须通过这个函数创建新词典

func (*Dictionary) GetIdFromName

func (d *Dictionary) GetIdFromName(name string) int

从名称得到整数ID 对从未见过的,为其创建新ID并返回,否则直接返回已有ID

func (*Dictionary) GetNameFromId

func (d *Dictionary) GetNameFromId(id int) string

从ID得到名称 如果ID不存在则返回空字符串

func (*Dictionary) MarshalJSON

func (m *Dictionary) MarshalJSON() ([]byte, error)

对Dictionary结构体进行JSON串行化

func (*Dictionary) TranslateIdFromName

func (d *Dictionary) TranslateIdFromName(name string) int

从名称得到整数ID 对从未见过的,返回-1,否则直接返回已有ID

func (*Dictionary) UnmarshalJSON

func (m *Dictionary) UnmarshalJSON(b []byte) error

对Dictionary结构体进行JSON反串行化

type DictionaryJSON

type DictionaryJSON struct {
	Words map[string]int
}

Dictionary结构体JSON串行化/反串行化临时存储结构体

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL