Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyword比较器在jdk7以上的情况下会报错 #133

Open
15797620308 opened this issue Jul 6, 2022 · 2 comments
Open

Keyword比较器在jdk7以上的情况下会报错 #133

15797620308 opened this issue Jul 6, 2022 · 2 comments

Comments

@15797620308
Copy link

public int compareTo(Keyword o) {
return this.tfidfvalue - o.tfidfvalue > 0.0D ? -1 : 1;
}
这段代码在jdk7以上会违反Comparator三大原则:自反性,传递性,对称性,所以强烈建议将此处代码进行修改
参考如下,以下代码做个测试,可行:
public int compareTo(Keyword o) {
return Double.compare(o.tfidfvalue, this.tfidfvalue);
}

@corgy-w
Copy link

corgy-w commented Aug 29, 2022

都停更这么久了 。

@linshouyi
Copy link

确实有这个问题。

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

No branches or pull requests

3 participants