Skip to content

Conversation

@da-liii
Copy link
Contributor

@da-liii da-liii commented Sep 12, 2024

What

Use hashset instead list for faster insertion and removal.

How to test your changes?

Use Goldfish.tmu as the test doc: https://github.com/LiiiLabs/goldfish/blob/main/Goldfish.tmu

register_vertex (tree v, soft_link ln) {
list<soft_link>& l= vertex_occurrences (v);
l = list<soft_link> (ln, l);
if (vertex_occurrences->contains (v)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么这里要判断v是否是vertex_occurrences的键?如果hashmap不包含对应的键,会原位构造对应的参数,然后返回引用。如果hashset没有默认初始化函数,可以在初始化vertex_occurrences的时候传个初始对象进去

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用原来的写法,编辑器直接卡死了。所以用了这种朴素的写法。

@Oyyko
Copy link
Contributor

Oyyko commented Sep 12, 2024

这块代码看起来没有问题。有经过测试,其他调用这块的代码,可以正常运行吗?

hashmap<tree, list<soft_link>> vertex_occurrences;
hashmap<string, int> type_count (0);
static int
hash (soft_link l) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数哪里用到了?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hashset<soft_link> 需要提供一个 hash函数

@da-liii
Copy link
Contributor Author

da-liii commented Sep 13, 2024

有经过测试,其他调用这块的代码,可以正常运行吗?

通过打开文档测试的,我尝试加一下集成测试

@da-liii da-liii marked this pull request as draft September 13, 2024 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants