Hashtable missing Hash Find Key pHash, data_of_key_to_find To sKey
issueid=647 25-07-2021 22:29
thinBasic MVPs
Number of reported issues by ReneMiner: 91
Hashtable missing Hash Find Key pHash, data_of_key_to_find To sKey

For the hash-table i am missing a function that would return the name(s) of the key(s) thats buckets content matches (completely or partially) the searched expression.

For example i create a hash as pDialogHandles that will hold the names of all used dialogs. The dialogs names are used as the keys for the hashtable.

I can request the handle of the dialog passing its name but the other way around there is no function that would return me the key if i pass the content of a bucket. All i can do is ask a list of all keys and then i had to iterate through all keys and compare the buckets content of each key until the matching
handle tells me: the key that i just tried is the one that i was looking for.

Isn't there any other way to obtain the keys name from the content of a bucket?
Dictionary-module has the ability of finding the key from given content as well as finding the content from a given key but i think the hash-table is already implemented to thincore - it were not necessary to use the dictionary-module if the hash-table would provide a way to retrieve the keys name when i have only
the content of a bucket to search for a match

If multiple buckets had the same content its probably to think about a way as passing a string variable byref for the resulting key,
lets say i have any kind of data, no matter how i stored it: i could pass the memory-position and the count of bytes using 2 parameters for that
- or just one
example

' Find  a Key to ( byref <data> as Anytype )   
' the above means only: arbitrary data that is present here 
' also present 
Dword pHash  ' the pointer of the table
String sKey  = ""   ' will receive the key hopefully, initially it must be empty so Hash_Find

' now make data uniform by covering it with a sequence of bytes:

Local bToSearch(SizeOf(<data>)) as Byte at GetAt(<data>)


' then i will pass this to 

While Hash_FindKey( pHash, sKey, [<options>]  bToSearch ) 

  ' it returned true:
  ' sKey now would hold the name of the (next) matching key

  If UserSatisfiedWith( sKey ) Then Exit While ' & bye bye

  ' user counts the key and memorizes (copies) it - or not -
   ' but sKey still holds the last found key 

Wend  ' this iteration the previously found key is passed back 
         ' and hopefully it could be used as the point where to 
        ' continue seaching for the next match
[<Options>] similar to array extract [StartsWith|EndsWith|Contains|=]

It were probably also thinkeable to have it working as function to extract multiple matches at once,
instead 1 dynamic string byref it were to pass a dynamic string array
string sDestinationArray()
Long lMatches = Hash_ExtractKeys pHash, [<Options>] bToSearch Into sDestinationArray
Issue Details
Issue Number 647
Issue Type Feature
Project thinBasic
Category Core engine (thinCore.dll)
Status Suggested
Priority 4
Suggested Version 2.0
Implemented Version (none)
Milestone (none)
Votes for this feature 0
Votes against this feature 0
Assigned Users (none)
Tags (none)




+ Reply