Skip to content

Commit 6cab916

Browse files
committed
Add Map.offset(of: Key) (untested).
1 parent c26e647 commit 6cab916

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/Map.swift

+7
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,13 @@ extension Map {
391391
return tree.offset(of: index)
392392
}
393393

394+
/// Returns the offset of the element with the given key, or `nil` if there is no such element.
395+
///
396+
/// - Complexity: O(log(`count`))
397+
public func offset(of key: Key) -> Int? {
398+
return tree.offset(forKey: key)
399+
}
400+
394401
/// Return the element stored at `offset` in this map.
395402
///
396403
/// - Complexity: O(log(`count`))

0 commit comments

Comments
 (0)