代码拉取完成,页面将自动刷新
package gopdf
//MapOfCharacterToGlyphIndex map of CharacterToGlyphIndex
type MapOfCharacterToGlyphIndex struct {
keyIndexs map[rune]int //for search index in keys
Keys []rune
Vals []uint
}
//NewMapOfCharacterToGlyphIndex new CharacterToGlyphIndex
func NewMapOfCharacterToGlyphIndex() *MapOfCharacterToGlyphIndex {
var m MapOfCharacterToGlyphIndex
m.keyIndexs = make(map[rune]int)
return &m
}
//KeyExists key is exists?
func (m *MapOfCharacterToGlyphIndex) KeyExists(k rune) bool {
/*for _, key := range m.Keys {
if k == key {
return true
}
}*/
if _, ok := m.keyIndexs[k]; ok {
return true
}
return false
}
//Set set key and value to map
func (m *MapOfCharacterToGlyphIndex) Set(k rune, v uint) {
m.keyIndexs[k] = len(m.Keys)
m.Keys = append(m.Keys, k)
m.Vals = append(m.Vals, v)
}
//Index get index by key
func (m *MapOfCharacterToGlyphIndex) Index(k rune) (int, bool) {
/*for i, key := range m.Keys {
if k == key {
return i, true
}
}*/
if index, ok := m.keyIndexs[k]; ok {
return index, true
}
return -1, false
}
//Val get value by Key
func (m *MapOfCharacterToGlyphIndex) Val(k rune) (uint, bool) {
i, ok := m.Index(k)
if !ok {
return 0, false
}
return m.Vals[i], true
}
//AllKeys get keys
func (m *MapOfCharacterToGlyphIndex) AllKeys() []rune {
return m.Keys
}
//AllVals get all values
func (m *MapOfCharacterToGlyphIndex) AllVals() []uint {
return m.Vals
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。