SortedList<TKey,TValue>.IndexOfKey(TKey) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
搜尋指定的鍵,並回傳整個 SortedList<TKey,TValue>內的零為基礎索引。
public:
int IndexOfKey(TKey key);
public int IndexOfKey(TKey key);
member this.IndexOfKey : 'Key -> int
Public Function IndexOfKey (key As TKey) As Integer
參數
- key
- TKey
鑰匙要在 SortedList<TKey,TValue>.
傳回
若找到,則為 在 key 整個 SortedList<TKey,TValue>內的零基指數;否則為 -1。
例外狀況
key 是 null。
備註
此方法執行二分搜尋;因此,此方法是一個 O(log n) 運算,其中 n 為 Count。