|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to get a KEY from a sorted list (not a VALUE) ??I have a SortedList "MySortedList". I want to get the KEY, not the VALUE. How can i do that ?? Possibly I want a O(1) operation: If MySortedList.ContainsKey(SomeObject) Then SomeObject_ContainedKey = MySortedList.??what????(SomeObject) End If PS. Please note that SomeObject and SomeObject_ContainedKey (the one I want to get) are *not* the same because clearly I am assuming ContainsKey return TRUE based on some comparer. -P Dim index As Integer = MySortedList.IndexOfKey(SomeObject)
If index >= 0 Then SomeObject_ContainedKey = MySortedList.GetKey(index) End If /claes <pamelaflue***@libero.it> wrote in message Show quoteHide quote news:1158337387.625736.175710@d34g2000cwd.googlegroups.com... > Hi, > > I have a SortedList "MySortedList". I want to get the KEY, not the > VALUE. How can i do that ?? Possibly I want a O(1) operation: > > > If MySortedList.ContainsKey(SomeObject) Then > > SomeObject_ContainedKey = MySortedList.??what????(SomeObject) > > End If > > > PS. > Please note that SomeObject and SomeObject_ContainedKey (the one I want > to get) are *not* the same because clearly I am assuming ContainsKey > return TRUE based on some comparer. > > > -P > |
|||||||||||||||||||||||