Code: Select all
NewMap txt.s()
AddMapElement(txt(),"abcd")
txt()="abcd"
AddMapElement(txt(),"bcde")
txt()="bcde"
AddMapElement(txt(),"cdef")
txt()="cdef"
; finding exact key
If FindMapElement(txt(),"cdef")
Debug "cdef found"
Debug MapKey(txt())
Else
Debug "cdef not found"
Debug MapKey(txt())
EndIf
; finding partial key
If FindMapElement(txt(),"bc")
Debug "BCDE found"
Debug MapKey(txt())
Else
Debug "BCDE not found"
Debug MapKey(txt())
EndIf
; finding exact key
If FindMapElement(txt(),"abcd")
Debug "abcd found"
Debug MapKey(txt())
Else
Debug "abcd not found"
Debug MapKey(txt())
EndIf
Code: Select all
cdef found
cdef
BCDE not found
cdef
abcd found
abcd
Is there any technique that allows finding closest map element by providing incomplete/partial key?
meaning, any faster technique apart from sequentially searching thru the list of map keys
As example shows, only exact key matches are taken in account and current element pointer shows last successful find (by exact key match).