Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node interface { // ID 返回节点 ID ID() uid.UID // Parent 返回父节点 Parent() Node // Children 返回子节点 ID 与对应节点的映射关系的一个只读副本 // 键为节点 ID 的十六进制表示 Children() map[string]Node // HasChild 返回是否有 ID 为 childID 的子节点 HasChild(childID uid.UID) bool // IsRoot 返回当前是否根节点 IsRoot() bool // IsLeaf 返回当前节点是否叶子节点 IsLeaf() bool // SetParent 设置父节点 SetParent(parent Node) // AddChild 添加子节点 // 添加成功则返回 true 、已经存在则返回 false AddChild(child Node) bool // DeleteChild 删除子节点 // 删除成功则返回 true 、不存在则返回 false DeleteChild(childID uid.UID) bool // Annotations 返回节点注解的副本 Annotations() map[string]string // AddAnnotation 添加注解 AddAnnotation(key, value string) // SetAnnotations 设置注解 SetAnnotations(anno map[string]string) // Data 返回节点存储数据的副本 Data() map[string][]byte // AddData 添加数据 AddData(key string, value []byte) // SetData 设置数据 SetData(data map[string][]byte) }
Node 树上的节点
type NodeDump ¶
type NodeDump struct { // 节点 ID ID string `json:"id"` // 子节点 Children []NodeDump `json:"children,omitempty"` // 注解 Annotations map[string]string `json:"annotations,omitempty"` // 数据 Data map[string][]byte `json:"data,omitempty"` }
NodeDump 导出的节点,可 JSON 序列化
type Tree ¶
type Tree interface { // Get 通过节点 ID 获取节点 Get(id uid.UID) (Node, bool) // GetByBranch 通过分支名获取节点 GetByBranch(name string) (Node, bool) // GetByTag 通过标签名获取节点 GetByTag(name string) (Node, bool) // Root 获取根节点 Root() Node // Tags 获取标签与节点的映射关系的一个只读副本 Tags() map[string]Node // Branches 获取分支与其头指针节点的映射关系的一个只读副本 Branches() map[string]Node // Search 通过 key 搜索节点 // // key 可以是各种形式的节点 ID 、分支名、标签名 Search(key string) (Node, bool) // AddNode 往树上添加节点 // // 如果 parentID 为 nil 就是插入根节点 AddNode(parentID uid.UID, node Node) error // AddTag 添加标签 // // 可以覆盖同名标签 AddTag(name string, nodeID uid.UID) error // DeleteTag 删除标签 // // 删除成功则返回 true 、不存在则返回 false DeleteTag(name string) bool // AddBranch 添加分支 // // 可以覆盖同名分支 AddBranch(name string, nodeID uid.UID) error // UpdateBranch 更新分支头指针 // // - force = true: 允许将分支头指针移动任何位置 // - force = false: 仅允许将分支头指针移动到当前位置的子节点 UpdateBranch(name string, nodeID uid.UID, force bool) error }
Tree 树
Click to show internal directories.
Click to hide internal directories.