gpt4 book ai didi

swift - Swift 的 Set.indexOf 的时间复杂度

转载 作者:可可西里 更新时间:2023-11-01 00:51:39 32 4
gpt4 key购买 nike

Set.indexOf 的时间复杂度是多少? documentation不说了,还有source委托(delegate)给某种内部存储类 (_VariantStorage/_VariantSetStorage),我找不到其来源。

最佳答案

documentation对于 CollectionType 表明它是 O(self.count)。

这是有道理的,因为最坏的情况是检查 Set(或任何其他集合)中的每个元素是否相等。它不应该比 O(self.count)复杂。

关于swift - Swift 的 Set.indexOf 的时间复杂度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36211396/

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