# Does \`Dictionary.Keys.contains(\_:)\` have \`O(1)\` time complexity?

**URL:** <https://forums.swift.org/t/does-dictionary-keys-contains-have-o-1-time-complexity/21647>\
**Category:** Using Swift\
**Created:** [March 15, 2019, 7:07pm UTC](https://forums.swift.org/t/does-dictionary-keys-contains-have-o-1-time-complexity/21647 "2019-03-15T19:07:07Z")\
**Posts on this page:** 1\
**Showing post:** 47

<div class="post-metadata">

**Author:** ![Jumhyn](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jumhyn/32/3891_2.png) [@Jumhyn](https://forums.swift.org/u/Jumhyn)\
**Post date:** [September 16, 2021, 3:44pm UTC](https://forums.swift.org/t/does-dictionary-keys-contains-have-o-1-time-complexity/21647/47 "2021-09-16T15:44:49Z")

</div>

The [docs](https://developer.apple.com/documentation/swift/hashable/2995575-hash) for `hash(into:)` itself are at least a bit more direct and avoid the "essential" terminology:

> The components used for hashing must be the same as the components compared in your type’s `==` operator implementation. Call `hasher.combine(_:)` with each of these components.

I've also [complained in the past](https://forums.swift.org/t/meaning-of-must-in-hashable-documentation/41544) about the lack of clarity in the documentation around `Hashable`, so I agree it would be great to beef it up with better explanation about the semantic requirements (and perhaps a brief elaboration on _why_ the requirements are the way they are, as discussed in this thread and others on the forums).

Also just want to say that this has been a great thread, have really enjoyed reading everyone's contributions.

---

_[View the full topic](https://forums.swift.org/t/does-dictionary-keys-contains-have-o-1-time-complexity/21647)._
