pywayne-data-structure

Data structure toolkit for logical condition trees, union-find operations, and XML file I/O. Use when working with tree-based data structures, set operations, union-find algorithms, or XML parsing and serialization.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "pywayne-data-structure" with this command: npx skills add wangyendt/data-structure

Pywayne Data Structure

数据结构工具集,提供逻辑条件树、并查集和 XML 文件读写功能。

Quick Start

from pywayne.data_structure import ConditionTree, UnionFind, XmlIO

# 逻辑条件树
tree = ConditionTree("root")
tree.append_by_path([{'tag': 'if', 'attrib': {}, 'text': '条件1'}])
tree.append_by_path([{'tag': 'else', 'attrib': {}, 'text': '条件2'}])

# 并查集操作
uf = UnionFind(10)
rep = uf.find(3)  # 返回集合标识
uf.union(1, 2)  # 合并两个集合

# XML 读写
xml_io = XmlIO("config.xml", "output.xml")
tree = xml_io.read()
xml_io.write("root", tree)

ConditionTree - 逻辑条件树

用于存储和管理条件表达式的树形结构。

初始化

from pywayne.data_structure import ConditionTree

tree = ConditionTree("root")

添加节点

通过路径列表添加节点。

# 根节点
tree.append_by_path([{'tag': 'if', 'attrib': {}, 'text': '条件1'}])

# 子节点
path = [{'tag': 'if', 'attrib': {}, 'text': '条件1-1'}]
tree.append_by_path(path)

节点字典格式{'tag': 标签名, 'attrib': 属性字典, 'text': 文本内容}

查找节点

按标签名查找find(nick_name) - 查找指定标签名的节点

tree.find("if")  # 返回 if 节点

按路径查找find_by_path(path) - 沿给定路径查找节点

node = tree.find_by_path(["root", "if", "条件1-1"])

打印树路径

打印从根到所有叶子的完整路径。

tree.print_path()

UnionFind - 并查集

并查集数据结构,支持按秩合并与路径压缩。

初始化

from pywayne.data_structure import UnionFind

uf = UnionFind(10)  # N 个元素

查找集合标识

rep = uf.find(3)  # 返回元素 3 所在集合的标识(整数)

合并集合

uf.union(1, 2)  # 合并集合 1 和 2

检查连接性

uf.connected(1, 2)  # 检查元素 1 和 2 是否在同一集合

元素计数

count = uf.count()  # 返回集合中元素数量

XmlIO - XML 读写

用于 XML 文件的读取和写入,支持与 ConditionTree 互转。

初始化

from pywayne.data_structure import XmlIO

xml_io = XmlIO("input.xml", "output.xml")

参数说明

参数类型说明
file_readstr待读取的 XML 文件路径
file_writestr待输出的 XML 文件路径

读取 XML

tree = xml_io.read()

返回:解析得到的 ConditionTree 对象

写入 XML

xml_io.write("root", tree)

参数说明

参数类型说明
root_namestr根节点名称,将作为 XML 根标签

应用场景

场景使用类
决策树逻辑ConditionTree
网络连接管理UnionFind
配置文件处理XmlIO

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Construction Claim Strategy

• Strategy before drafting. Decide direction, scope, and argument before choosing clauses. • 7 dimensions. Situation, scope, direction, argument, disclosure, response architecture, risk. • All major contract forms. FIDIC, PSSCOC, NEC, SIA, JCT, and bespoke.

Registry SourceRecently Updated
General

Goldman Sachs Co

提供高盛公司历史、业务模式、市场地位及关键数据,助力研究投资银行和金融机构角色分析。

Registry SourceRecently Updated
General

Goldfish

Goldfish是Pepperidge Farm旗下标志性小鱼形儿童零食,始于1962年,北美市场销量领先且覆盖多口味多渠道。

Registry SourceRecently Updated
General

Dailymotion

法国的视频分享平台,2005年创立,Vivendi持有,聚焦欧洲和中东市场,提供优质内容与媒体合作,月活超3亿用户。

Registry SourceRecently Updated