Jump to content


Photo

New data structure - a hash table / key-value table (?)


  • Please log in to reply
No replies to this topic

#1 Anonym

Anonym

    Advanced Member

  • UBot Users
  • PipPipPip
  • 496 posts
  • Location127.0.0.1
  • OS:Windows XP
  • Total Memory:4Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 22 February 2012 - 03:35 PM

One thing that would be really nice to see in a future release of UBot Studio is a new data structure and the operations on such a data structure. The datastructure I am thinking of is a key-value pair (a hash table), or actually a key-value multiples using open hashing.

In my mind this could be a custom table with a special tweak, the ability to address a certain row in the table with a key (not a numerical value, well, in reality and hidden in the from the interface this is probably the way it works anyway under the hood so to speak). The operations should be similar to that of the list with one difference, no numeric values to address the rows but rather a string.



+-------------+-------------+-------------+-------------+
|             |             |             |             |
|  chrysler   |    EWING    |     blue    |    2008     |
|             |             |             |             |
+-------------+-------------+-------------+-------------+
|             |             |             |             |
|   volvo     |   RKS786    |    black    |    2010     |
|             |             |             |             |
+-------------+-------------+-------------+-------------+
|             |             |             |             |
|   porsche   |  LKMW7871   |    silver   |             |
|             |             |             |             |
+-------------+-------------+-------------+-------------+


Operations on such a keyvalue table could be almost the same way as for lists, but the addressing of a row in such a keyvalue table should not be a numerical value, but instead a string - the key.

So such functions might be (assuming the name of the datastructure is "keyvalue")

$previous keyvalue row
$next keyvalue row
$previous keyvalue item
$next keyvalue item
$keyvalue item
$keyvalue from file (probably a custom CSV file where the buckets are saved in columns)
$keyvalue from text
$text from keyvalue
$subtract keyvalue
$sort keyvalue
$common keyvalue items
$keyvalue cell
$keyvalue total columns
$keyvalue total rows


Commands could be:

add item to keyvalue
add keyvalue to keyvalue (merging or appending to keyvalue tables)
remove item from keyvalue
set keyvalue position ====>>> with a string, not a numerical value
clear keyvalue
create keyvalue from file
set keyvalue cell
add list to keyvalue as column
add list to keyvalue as row


...possibly some more (or less).


So for finding the row associated with volvo above and update the color to pink it might look like


set keyvalue position("volvo", &keyvalueHash )
set keyvalue cell(&keyvalueHash, 1, "pink")   // yes, column 1 because the implementation should be hidden




The way I see it this is kind of a hash table with a open hashing as collision resolution.

For those wanting to know more there is this URL:

http://en.wikipedia.org/wiki/Hash_table


It was a looooong time ago since I worked with any of this so I feel a bit rusty, least to say...




So, Eddie, when will this be implemented? Next release? ;) :D

Seriously, is it a bad idea? Good idea? Good idea and no time to do it? Am I dreaming too much?


(and yes, I am aware of that there are a lot of work related to implementing this.)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users