-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangxiao1024
committed
Jul 24, 2024
1 parent
b9ba5db
commit 90f6ddf
Showing
3 changed files
with
51 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
package dict | ||
|
||
// Consumer is used to traversal dict, if it returns false the traversal will be break | ||
// Consumer 是一个遍历字典时使用的函数类型,如果返回false,则终止遍历 | ||
type Consumer func(key string, val interface{}) bool | ||
|
||
// Dict is interface of a key-value data structure | ||
// Dict 是 key-value 数据结构的接口定义 | ||
type Dict interface { | ||
Get(key string) (val interface{}, exists bool) | ||
Len() int | ||
Put(key string, val interface{}) (result int) | ||
PutIfAbsent(key string, val interface{}) (result int) | ||
PutIfExists(key string, val interface{}) (result int) | ||
Remove(key string) (val interface{}, result int) | ||
ForEach(consumer Consumer) | ||
Keys() []string | ||
RandomKeys(limit int) []string | ||
Get(key string) (val interface{}, exists bool) // 获取键的值 | ||
Len() int // 返回字典的长度 | ||
Put(key string, val interface{}) (result int) // 插入键值对 | ||
PutIfAbsent(key string, val interface{}) (result int) // 如果键不存在,则插入 | ||
PutIfExists(key string, val interface{}) (result int) // 如果键存在,则插入 | ||
Remove(key string) (val interface{}, result int) // 移除键 | ||
ForEach(consumer Consumer) // 遍历字典 | ||
Keys() []string // 返回所有键的列表 | ||
RandomKeys(limit int) []string // 随机返回一定数量的键 | ||
RandomDistinctKeys(limit int) []string | ||
Clear() | ||
Clear() // 清除字典中的所有元素 | ||
DictScan(cursor int, count int, pattern string) ([][]byte, int) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters