gpt4 book ai didi

用于性能考虑的 Javadoc 标记

转载 作者:行者123 更新时间:2023-12-02 03:23:40 40 4
gpt4 key购买 nike

是否有出于性能考虑的javadoc标签?

人们可以想象:

/**
* ...other javadoc tags...
* @perform Expected to run in O(n) time if image exists with O(k) memory usage
*/
public Image getImage(URL url, String name) {
//code goes here

如果它不是内置的,是否有一些人们使用的事实上的自定义标签?

最佳答案

从 Java 8 开始,出于这种考虑添加了一个名为 @implNote 的新标签。

正如 here 所描述的,它可以这样使用:

/**
* Picks the winners from the specified set of players.
* <p>
* The returned list defines the order of the winners, where the first
* prize goes to the player at position 0. The list will not be null but
* can be empty.
* @implNote This implementation has linear runtime and does not filter out
* null players.
* @param players
* the players from which the winners will be selected
* @return the (ordered) list of the players who won; the list will not
* contain duplicates
* @since 1.1
*/
default List<String> pickWinners(Set<String> players) {
return new ArrayList<>(players);
}

还添加了两个其他标签,在 this 问题中进行了讨论。

值得注意的是,有一些细节说明这些不是 javadoc 规范的一部分,而是被 oracle 使用并在 JDK 中广泛使用。因此,与上述相同的来源详细说明您必须使用以下命令行选项来启用它们:

-tag "apiNote:a:API Note:"
-tag "implSpec:a:Implementation Requirements:"
-tag "implNote:a:Implementation Note:"

它们在 IDE 之间的支持程度不同(例如,您无法在 Eclipse 中设置上述命令行参数),这使得它们的用处不大。

关于用于性能考虑的 Javadoc 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39278635/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com