Documentation
¶
Index ¶
- Constants
- Variables
- func HashInt(s interface{}) int
- func HashValueToBytes(hashValue HashValue) ([]byte, error)
- func KeyToInt(key interface{}) int
- type Block
- type HashTable
- func (ht *HashTable) Get(key string) (interface{}, error)
- func (ht *HashTable) Index(keyInt int) *Block
- func (ht *HashTable) Keys() ([]interface{}, error)
- func (ht *HashTable) Set(key string, value interface{}) error
- func (ht *HashTable) SetByType(key string, value interface{}, tp string) error
- func (ht *HashTable) String() string
- func (ht *HashTable) ToMap() (map[string]interface{}, error)
- type HashValue
Constants ¶
View Source
const HashTableLength int = 100 // 哈希表默认长度
HashTableLength 哈希表默认数组长度
Variables ¶
View Source
var Content []byte // 存储
View Source
var FreeLength int // 剩余空间大小
View Source
var FreeList []*Block // 空闲存储块
View Source
var UsedList []*Block // 已使用的存储块
Functions ¶
func HashValueToBytes ¶
Types ¶
type Block ¶
type Block struct { Offset int // 存储空间 Content 中的 offset Length int // 存储空间 Content 中的 length Next *Block }
Block 存储块
func (*Block) GetContent ¶
type HashTable ¶
HashTable 哈希表 理论上讲哈希表的 value 应该是 HashValue,即哈希表应该是 HashValue 的数组; 但是因为要控制内存空间的大小,所以必须将HashValue 存储在 block 中,所以哈希表的 value 是 block 的指针。
func MapToHashTable ¶
MapToHashTable 将 map 对象装成 HashTable
func NewHashTable ¶
func NewHashTable() *HashTable
type HashValue ¶
type HashValue struct { Key interface{} Value interface{} // value 可以是 int/string等标准类型,也可以是 HashTable 类型 Type string // 类型,指明 value 是值还是 HashTable,可选值有 ValueType / HashType }
HashValue 哈希表 value 结构
func HashValueFromBytes ¶
func (*HashValue) IsHashType ¶
Click to show internal directories.
Click to hide internal directories.