Skip to content
Sasha Crofter edited this page Jun 5, 2012 · 2 revisions

DataLib is a library for managing arbitrary amounts of data with relative speed and efficiency.

Hash Table

Subroutines for creating and searching hash tables, which are sorted tables that store values under names

dl.makeHashTable (headerPointer, indicies, startingLength)

Creates the header for a hashTable at headerPointer with indicies as the target number of indicies for the hashTable. The total length of the hashTable is 2 * indicies + 4, which includes the header, the lookup portion of the table, and the value portion of the table. length is not the total length of the table, but rather the number of occupied indicies. returns headerPointer

dl.hashGet (searchTerm, hashTablePointer)

Searches the hash table at hashTablePointer for searchTerm in the lookup portion of it. It returns the value in the value portion associated with the searchTerm.

returns value associated by the hash table with searchTerm, or 1 if it could not be found development version

dl.hashInsert (lookupValue, insertValue, hashTablePointer)

Inserts lookupValue in a sorted way in the lookup portion of the hashTable at hashTablePointer and insertValue in an unsorted way at the same index in the value portion of the table. This is designed to work very well with the 16-bit hashing algorithm crp.dsHash.

under development

Sorted Table

Subroutines for creating and searching sorted tables

dl.sortedInsert (insertValue, tableLocation, tableLength)

Inserts insertValue into the sorted table at tableLocation of tableLength, maintaining the sortedness of the table.

returns location of insert, or 1 if the value is already present in the table

dl.searchValTable (searchTerm, tableLocation, tableLength)

Performs a binary search on the table at tableLocation (with length tableLength) for searchTerm and returns the memory location

dl.findInsertIndex (searchTerm, tableLocation, tableLength)

Returns the index at which searchTerm should be inserted to keep the table at tableLocation with length tableLength sorted.

dl.unsortedInsert (insertValue, insertLocation)

Inserts insertValue at insertLocation and pushes the value it would replace upward in memory recursively until only a null is overwritten. returns insertLocation

Clone this wiki locally