vb.net - Find Item Of Structure in List (Of Structure) -
i have struct:
private structure udtt9map dim keyboardkey string dim mobilebutton integer end structure
they stored in
private _list list(of udtt9map)
i know if there fast way locate item in list giving keyboardkey.
since e. g. "keyboardkey" theoretically occur multiple times, guess ms did not include such function because multiple items list returned.
am wrong?
thank much!
a list doesn't have means of finding items. locating items in list o(n) operation, i.e. need loop through entire list , compare value each structure. fast lookup rather use dictionary of lists:
private _dict dictionary(of string, list(of udtt9map))
by storing structures same keyboardkey
value in list in dictionary using keyboardkey
value key, can structures value fast. reading dictionary close o(1) operation.
to list use:
dim result list(of udtt9map) = _dict(key)
if keyboardkey
values known unique in collection, don't need dictionary of lists, can use dictionary of structure:
private _dict dictionary(of string, udtt9map)
to item use:
dim result udtt9map = _dict(key)
Comments
Post a Comment