We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
依赖树本身的加载很简单,您所需要的只是从键(例如名称)到对象的一些映射。
你没有指定任何语言,所以我选择了Python。预期的输入是一个格式为“[名称]:[空格分隔的依赖项]”的行文件。
此代码假设未列出的任何项目都具有零依赖性,并且如果需要,您可以遍历树以添加空条目。至少你应该检查递归依赖关系。
示例:
[注意:我采取了快捷方式,因为我确实不需要行文件,而是需要行的可迭代(文件满足),所以我将行列表传递给函数。]
您可以构建所有行在此基本结构之上的各种功能,并将其和这些概念(例如依赖、推荐、建议,甚至冲突、替换等)封装到特定于您的系统的各种对象中。
The dependency tree itself is trivial to load, all you need is some mapping from keys (such as names) to objects.
You've not specified any language, so I've chosen Python. The expected input is a file of lines in the form "[name]: [space separated dependencies]".
This code assumes any item not listed has zero dependencies, and you could traverse the tree to add empty entries if desired. At the very least you should check for recursive dependencies.
Example:
[Note: I take a shortcut, since I really don't require a file of lines, but an iterable of lines (which a file meets), so I pass a list of lines to the function.]
You can build all sorts of functions on top of this basic structure, and encapsulate it and those concepts (like depends vs recommends vs suggests, and even conflicts vs replaces, etc.) into various objects specific to your system.
许多其他概念也涉及依赖树,例如SNMP MIB解析、C/C++源代码编译。因此,您可以参考任何其他讨论此问题的材料:)
Many other concepts also involve dependency trees, such as SNMP MIB resolution, C/C++ source code compiling. So you can reference any other materials that talk about this :)