SubTrie
public struct SubTrie<Key, Value> : Sendable where Key : Collection, Key : Sendable, Value : Sendable, Key.Element : Hashable, Key.Element : Sendable
extension SubTrie: CustomStringConvertible
A part of a trie.
-
The type of a trie projected by an instance of
Self.Declaration
Swift
public typealias Base = Trie<Key, Value> -
The root of this sub-tree.
Declaration
Swift
fileprivate let root: Base.Node.Identifier -
The number of key/value pairs in
self.Declaration
Swift
public var count: Int { get } -
Returns a collection with the key/value pairs in
self.Declaration
Swift
public var elements: Base.Elements { get } -
Accesses the value associated with
key.Declaration
Swift
public subscript<K>(key: K) -> Value? where K : Collection, K : Sendable, Key.Element == K.Element { get } -
Returns a sub-trie mapping the keys prefixed by
keyto their corresponding value inself, ornilifselfcontains no key starting with bykey.Declaration
Swift
public subscript<K>(prefix key: K) -> SubTrie? where K : Collection, K : Sendable, Key.Element == K.Element { get } -
Returns a pair
(n, i)such thatkey[..<i]is the longest key prefix contained inselfandnis a sub-trie mapping the keys prefixed bykey[..<i]to their corresponding value inself.Declaration
Swift
public func longestPrefix<K: Collection & Sendable>( startingWith key: K ) -> (trie: SubTrie<Key, Value>, position: K.Index) where K.Element == Key.Element -
Declaration
Swift
public var description: String { get }
View on GitHub