I have a script at work where we have several different data tables in a format similar to the following:
Table Name: HingeArms Hght Part #1 Part #2 33 S-HG-088-00 S-HG-089-00 41 S-HG-084-00 S-HG-085-00 49 S-HG-033-00 S-HG-036-00 57 S-HG-034-00 S-HG-037-00
If the first column (and possibly more) contains numerical data sorted in ascending order and represents a range for determining the correct record of data to receive (for example, height <= 33, then part 1 = S-HG-088-00, height < = 41, then part 1 = S-HG-084-00, etc.)
I need to find and select the closest match to a given value. For example, given height = 34.25, I need to get the second entry in the above set:
41 S-HG-084-00 S-HG-085-00
These tables are currently stored in the VB.NET Hashtable cache for data loaded from a CSV file, where the key for the Hashtable is an integral part of the table name and one or more columns from the table that represent the "key" for writing. For example, for the above Hashtable Add table for the first record would be:
ht.Add("HingeArms,33","S-HG-088-00,S-HG-089-00")
This seems less optimal, and I have some flexibility to change the structure if necessary (the cache contains data from other tables where direct search is possible ... these "range" tables were simply dumped because it was "easy",). I was looking for the Next method in the Hashtable / Dictionary to give me the closest matching record in a range, but this is clearly not available in stock classes in VB.NET.
Any ideas on how I can do what I'm looking for with a Hashtable or in another framework? It must be executed, since the search will often be called up in different sections of the code. Any thoughts would be greatly appreciated. Thanks.