pine.HashTable: Functions Types Modinfo Source  

Data structures/Hash tables

A hash table is a data structure that sacrifices memory usage in favor of supremely efficient retrieval and insertion. Every object stored into a hash table is associated with a key which it can be retrieved with again.

Hash tables only afford an advantage while they are large enough to not encounter tons of key collisions - in essence, if your hash table is nearly full (which you can check using HashFilled) you ought to use ResizeHash to allocate for it more space.

To create a hash table, use the CreateHash command. You can insert key and value pairs into using HashInsert, find them using HashFind, and take them out using HashRemove. This hash table implementation moves key and value pairs to the front of the bucket when they are accessed, and this requires extremely little overhead. This behavior can be switched off using HashSetBringToFront. That would not be recommended, however, for most applications.

To visit all the objects in a hash table you can use an EachIn loop.

Functions Summary

ClearHash Clear the contents of a hash table.
CopyHash Copy a hash table.
CountHash Count the number of elements in the hash table.
CreateHash Create a new hash table.
CreateHashNode Create a new hash table node.
dbgHashKey Native hash function.
HashBucket Find the bucket of the hash table at the specified index.
HashDeepest Find the bucket in the hash table with the greatest number of elements.
HashDeepestBucket Find the bucket in the hash table with the greatest number of elements.
HashDeepestNodeBucket Find the bucket in the hash table with the greatest number of elements.
HashDepth Find the most number of elements in any bucket.
HashFilled Determine the number of occupied buckets in the hash table.
HashFind Find the first value corresponding to some key in the hash table.
HashFindAll Find all the values corresponding to some key in the hash table.
HashFindAllNodes Find all the nodes with some key in the hash table.
HashFindNode Find the first node with some key in the hash table.
HashGetBringToFront Get whether values are brought to the front of a bucket for quicker finding in the future whenever they are accessed.
HashInsert Insert a new key and value pair into a hash table.
HashInsertNode Insert a node into a hash table.
HashKeys Returns an iterator object to that can be used with EachIn.
HashNodeBucket Find the bucket of the hash table at the specified index.
HashNodeKey Gets node key.
HashNodes Returns an iterator object to that can be used with EachIn.
HashNodeValue Gets node value.
HashObjects Returns an iterator object to that can be used with EachIn.
HashRemove Remove the first node with a given key.
HashRemoveAll Remove all the nodes with a given key.
HashRemoveAllNodes Remove all the nodes with a given key.
HashSetBringToFront Set whether values are brought to the front of a bucket for quicker finding in the future whenever they are accessed.
HashSize Get the size of a hash table.
ResizeHash Resize a hash table.

Types Summary

HashNode A hash table node object.
HashTable A hash table object.

Functions

Function ClearHash(hash:HashTable)
DescriptionClear the contents of a hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put some things in it
For Local x%=1 To 8
	HashInsert hash,x,String(x)
Next

'how many things does it have in it?
Print "Number of elements: "+CountHash(hash)

'now clear it
Print "Clearing the hash table..."
ClearHash hash

'and how many things does it have in it now?
Print "Number of elements: "+CountHash(hash)

Function CopyHash:HashTable(hash:HashTable)
ReturnsA new hash table containing all the same key and value pairs as the previous and possessing the same characteristics.
DescriptionCopy a hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put some things in it
For Local x%=1 To 8
	HashInsert hash,x,String(x)
Next

'copy it
Local hash_2:HashTable=CopyHash(hash)

'clear the first one
ClearHash hash

'now print out the contents of the copied one
For Local str$=EachIn hash_2
	Print str
Next

Function CountHash:Int(hash:HashTable)
ReturnsThe number of nodes.
DescriptionCount the number of elements in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'print the number of nodes
Print "Number of nodes: "+CountHash(hash)

Function CreateHash:HashTable(size:Int,hashfunction:Int(str:String)=dbgHashKey)
ReturnsA new hash table.
DescriptionCreate a new hash table.
Informationhashfunction should be a function that takes a string as an argument and returns an integer. For best results, the hash function's distribution of keys should be as close to uniform as possible.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

Function CreateHashNode:HashNode(key:String,value:Object)
ReturnsThe new node.
DescriptionCreate a new hash table node.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert a new node
Local node:HashNode=HashInsert(hash,"c'mon baby","do the locomotion")

'now print some info about it
Print "node key: "+HashNodeKey(node)
Print "node value: "+String(HashNodeValue(node))

Function dbgHashKey:Int(s:String)
ReturnsA hash.
DescriptionNative hash function.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'print out the hashes of some strings
Print dbgHashKey("na na na na na na na na na na na na na na na na")
Print dbgHashKey("batman!")
Print dbgHashKey("holy smokes!")

Function HashBucket:TList(hash:HashTable,index:Int)
ReturnsThe TList which serves as the bucket at that index, contains values.
DescriptionFind the bucket of the hash table at the specified index.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'fill it with a ton of crap
For Local x%=1 To 256
	HashInsert hash,x,String(x)
Next

'get the bucket at index 2
Local bucket:TList=HashBucket(hash,2)

'now print out its contents
For Local str$=EachIn bucket
	Print str
Next

Function HashDeepest:Int(hash:HashTable)
ReturnsThe index of the bucket in the hash table with the greatest depth.
DescriptionFind the bucket in the hash table with the greatest number of elements.
InformationWhen more than one bucket is tied for the greatest depth, the one with the lowest index will be returned.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert a lot of nodes
For Local x%=1 To 128
	HashInsert hash,x,String(x)
Next

'print the greatest depth of any single bucket
Print "Greatest depth: "+HashDepth(hash)
Print "And it belongs to bucket no. "+HashDeepest(hash)

Function HashDeepestBucket:TList(hash:HashTable)
ReturnsThe TList which is the bucket in the hash table with the greatest depth, contains values.
DescriptionFind the bucket in the hash table with the greatest number of elements.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put a bunch of stuff into it
For Local x%=1 To 64
	HashInsert hash,x,String(x)
Next

'get the deepest bucket
Local bucket:TList=HashDeepestBucket(hash)

'print out its contents
For Local str$=EachIn bucket
	Print str
Next

Function HashDeepestNodeBucket:TList(hash:HashTable)
ReturnsThe TList which is the bucket in the hash table with the greatest depth, contains nodes.
DescriptionFind the bucket in the hash table with the greatest number of elements.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put a bunch of stuff into it
For Local x%=1 To 64
	HashInsert hash,x,String(x)
Next

'get the deepest bucket
Local bucket:TList=HashDeepestNodeBucket(hash)

'print out its contents
For Local node:HashNode=EachIn bucket
	Print HashNodeKey(node)
Next

Function HashDepth:Int(hash:HashTable)
ReturnsThe maximum number of nodes in a single bucket.
DescriptionFind the most number of elements in any bucket.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert a lot of nodes
For Local x%=1 To 128
	HashInsert hash,x,String(x)
Next

'print the greatest depth of any single bucket
Print "Greatest depth: "+HashDepth(hash)
Print "And it belongs to bucket no. "+HashDeepest(hash)

Function HashFilled:Int(hash:HashTable)
ReturnsThe number of buckets containing at least one node.
DescriptionDetermine the number of occupied buckets in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert a few nodes
Print "Inserting 18 elements..."
For Local x%=1 To 18
	HashInsert hash,x,String(x)
Next

'print the number of buckets containing at least one element
Print "Number of buckets containing at least one element: "+HashFilled(hash)

Function HashFind:Object(hash:HashTable,key:String)
ReturnsThe first value associated with the given key.
DescriptionFind the first value corresponding to some key in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert some nodes
HashInsert hash,"snake","scary"
HashInsert hash,"spider","scary"
HashInsert hash,"hornet","scary"
HashInsert hash,"kitten","adorable"
HashInsert hash,"puppy","adorable"
HashInsert hash,"rabbit","adorable"

'find some of those values
Print "A hornet is: "+String(HashFind(hash,"hornet"))
Print "A puppy is: "+String(HashFind(hash,"puppy"))

Function HashFindAll:TList(hash:HashTable,key:String)
ReturnsA list of the values associated with the given key.
DescriptionFind all the values corresponding to some key in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert some nodes
HashInsert hash,"color","red"
HashInsert hash,"color","green"
HashInsert hash,"color","violet"
HashInsert hash,"number","one"
HashInsert hash,"number","two"
HashInsert hash,"number","nineteen"

'find some of those values
Print "All the values with the key 'color':"
For Local str$=EachIn HashFindAll(hash,"color")
	Print str
Next

'find more of those values
Print "All the values with the key 'number':"
For Local str$=EachIn HashFindAll(hash,"number")
	Print str
Next

Function HashFindAllNodes:TList(hash:HashTable,key:String)
ReturnsA list of the nodes with the given key.
DescriptionFind all the nodes with some key in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert some nodes
HashInsert hash,"color","orange"
HashInsert hash,"color","purple"
HashInsert hash,"color","yellow"
HashInsert hash,"number","nine"
HashInsert hash,"number","eight"
HashInsert hash,"number","seven"

'find some of those values
Print "All the nodes with the key 'color':"
For Local node:HashNode=EachIn HashFindAllNodes(hash,"color")
	Print "key: '"+HashNodeKey(node)+"' value: '"+String(HashNodeValue(node))+"'"
Next

'find more of those values
Print "All the nodes with the key 'number':"
For Local node:HashNode=EachIn HashFindAllNodes(hash,"number")
	Print "key: '"+HashNodeKey(node)+"' value: '"+String(HashNodeValue(node))+"'"
Next

Function HashFindNode:HashNode(hash:HashTable,key:String)
ReturnsThe first encountered node with the given key.
DescriptionFind the first node with some key in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert some stuff
HashInsert hash,"1","one"
HashInsert hash,"2","two"
HashInsert hash,"3","three"
HashInsert hash,"4","four"

'get one of the stuffs
Local node:HashNode=HashFindNode(hash,"3")

'print out its value
Print String(HashNodeValue(node))

Function HashGetBringToFront:Int(hash:HashTable)
ReturnsThe boolean value.
DescriptionGet whether values are brought to the front of a bucket for quicker finding in the future whenever they are accessed.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'is the bringtofront flag set?
Print "Bring nodes to front of buckets when accessed? "+HashGetBringToFront(hash)

'set it to false
Print "Setting the flag to false..."
HashSetBringToFront hash,False

'how about now?
Print "Bring nodes to front of buckets when accessed? "+HashGetBringToFront(hash)

Function HashInsert:HashNode(hash:HashTable,key:String,value:Object)
ReturnsThe node in the hash table containing this new data.
DescriptionInsert a new key and value pair into a hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'now put something in it!
HashInsert hash,"key","value"

Function HashInsertNode(hash:HashTable,node:HashNode)
DescriptionInsert a node into a hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'if you liked it then you shoulda put a node in it
HashInsertNode hash,CreateHashNode("key","value")

Function HashKeys:HashEnum(hash:HashTable)
ReturnsAn iterator object.
DescriptionReturns an iterator object to that can be used with EachIn.
InformationIterates through the keys in the hash table, if a key appears in the hash table more than once then it will go to the iterator more than once.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put some numbers in it
For Local x%=1 To 24
	HashInsert hash,x,String(x)
Next

'now iterate through the keys and print all the stuff out
For Local str$=EachIn HashKeys(hash)
	Print str
Next

Function HashNodeBucket:TList(hash:HashTable,index:Int)
ReturnsThe TList which serves as the bucket at that index, contains nodes.
DescriptionFind the bucket of the hash table at the specified index.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'fill it with a ton of crap
For Local x%=1 To 256
	HashInsert hash,x,String(x)
Next

'get the bucket at index 2
Local bucket:TList=HashNodeBucket(hash,2)

'now print out its contents
For Local node:HashNode=EachIn bucket
	Print HashNodeKey(node)
Next

Function HashNodeKey:String(node:HashNode)
ReturnsThe node's key.
DescriptionGets node key.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert a new node
Local node:HashNode=HashInsert(hash,"c'mon baby","do the locomotion")

'now print some info about it
Print "node key: "+HashNodeKey(node)
Print "node value: "+String(HashNodeValue(node))

Function HashNodes:HashNodeEnum(hash:HashTable)
ReturnsAn iterator object.
DescriptionReturns an iterator object to that can be used with EachIn.
InformationIterates through the nodes in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put a bunch of letters in it
For Local x%=Asc("a") To Asc("z")
	HashInsert hash,x,Chr(x)
Next

'now iterate through the nodes and print all the stuff out
For Local node:HashNode=EachIn HashNodes(hash)
	Print HashNodeKey(node)+" : "+String(HashNodeValue(node))
Next

Function HashNodeValue:Object(node:HashNode)
ReturnsThe node's value.
DescriptionGets node value.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'insert a new node
Local node:HashNode=HashInsert(hash,"c'mon baby","do the locomotion")

'now print some info about it
Print "node key: "+HashNodeKey(node)
Print "node value: "+String(HashNodeValue(node))

Function HashObjects:HashEnum(hash:HashTable)
ReturnsAn iterator object.
DescriptionReturns an iterator object to that can be used with EachIn.
InformationIterates through the objects in the hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put some numbers in it
For Local x%=1 To 24
	HashInsert hash,x,String(x)
Next

'now iterate through the objects and print all the stuff out
For Local str$=EachIn HashObjects(hash)
	Print str
Next

Function HashRemove:HashNode(hash:HashTable,key:String)
ReturnsThe node that was removed.
DescriptionRemove the first node with a given key.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put some stuff in it
HashInsert hash,"cougar","cat"
HashInsert hash,"lion","cat"
HashInsert hash,"jaguar","cat"
HashInsert hash,"wolf","dog"
HashInsert hash,"hound","dog"

'go through and print it all
Print "Contents:"
For Local str$=EachIn hash
	Print str
Next

'now take some of them out
Print "Taking out two cats and one dog..."
HashRemove hash,"jaguar"
HashRemove hash,"lion"
HashRemove hash,"hound"

'go through and print what's left
Print "Contents:"
For Local str$=EachIn hash
	Print str
Next

Function HashRemoveAll:Int(hash:HashTable,key:String)
ReturnsThe number of nodes that were removed.
DescriptionRemove all the nodes with a given key.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put some stuff in it
HashInsert hash,"bear","panda"
HashInsert hash,"bear","grizzly"
HashInsert hash,"bear","black"
HashInsert hash,"bird","chickadee"
HashInsert hash,"bird","robin"
HashInsert hash,"rock","n roll"
HashInsert hash,"rock","granite"
HashInsert hash,"rock","hematite"

'go through and print it all
Print "Contents:"
For Local node:HashNode=EachIn HashNodes(hash)
	Print HashNodeKey(node)+" : "+String(HashNodeValue(node))
Next

'now take some of them out
Print "Removing all the birds..."
HashRemoveAll hash,"bird"

'go through and print what's left
Print "Contents:"
For Local node:HashNode=EachIn HashNodes(hash)
	Print HashNodeKey(node)+" : "+String(HashNodeValue(node))
Next

'now take more of them out
Print "Removing all the bears..."
HashRemoveAll hash,"bear"

'and go through and print what's left one more time
Print "Contents:"
For Local node:HashNode=EachIn HashNodes(hash)
	Print HashNodeKey(node)+" : "+String(HashNodeValue(node))
Next

Function HashRemoveAllNodes:TList(hash:HashTable,key:String)
ReturnsA list containing all the nodes which were removed.
DescriptionRemove all the nodes with a given key.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'put some stuff in it
HashInsert hash,"plant","tree"
HashInsert hash,"plant","vine"
HashInsert hash,"vehicle","car"
HashInsert hash,"vehicle","plane"

'remove the nodes with the key 'plant'
Local list:TList=HashRemoveAllNodes(hash,"plant")

'now print out the removed items
For Local node:HashNode=EachIn list
	Print String(HashNodeValue(node))
Next

Function HashSetBringToFront(hash:HashTable,bringtofront:Int)
DescriptionSet whether values are brought to the front of a bucket for quicker finding in the future whenever they are accessed.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'is the bringtofront flag set?
Print "Bring nodes to front of buckets when accessed? "+HashGetBringToFront(hash)

'set it to false
Print "Setting the flag to false..."
HashSetBringToFront hash,False

'how about now?
Print "Bring nodes to front of buckets when accessed? "+HashGetBringToFront(hash)

Function HashSize:Int(hash:HashTable)
ReturnsThe size of the hash table.
DescriptionGet the size of a hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'but that's not enough - 
'we want To Print out the size of it, too!
Print "Size: "+HashSize(hash)

Function ResizeHash(hash:HashTable,size:Int)
DescriptionResize a hash table.
InformationCreates a new hash table of the same size, inserts all the values inside this hash table into it, then makes the new hash table become this hash table.
Example
SuperStrict

'import required modules
Framework brl.standardio
Import pine.HashTable

'create a new hash table object of size 32
Local hash:HashTable=CreateHash(32)

'print out the size of it
Print "Size: "+HashSize(hash)

'and now resize it
Print "Resizing the hash table..."
ResizeHash hash,64

'print out the size of it again
Print "New size: "+HashSize(hash)

Types

Type HashNode
DescriptionA hash table node object.
Functions Summary
Create Create a new hash table node.
Function Create:HashNode(key$,value:Object)
ReturnsA new hash table node.
DescriptionCreate a new hash table node.

Type HashTable
DescriptionA hash table object.
Methods Summary
bucket Get the contents of the bucket at some index as objects.
checkfill Determine the number of buckets occupied by at least one element.
clear Clear the contents of the hash table.
copy Create a copy of the hash table.
count Determine the number of elements in the hash table.
find Get the first object associated with a key.
findall Get all the objects associated with a key.
findallnodelinks Find the list links of all the nodes with a given key.
findallnodes Get all the nodes with a key.
findnode Get the first node with a key.
findnodelink Find the list link of either a specific node or the first node with a given key.
insert Insert a key and value pair into the hash table.
insertnode Insert a node into the hash table.
KeyEnumerator Method implements EachIn support.
maxbucket Find the bucket with the greatest number of elements.
maxbucketdepth Find the greatest number of elements contained in a single bucket.
NodeEnumerator Method implements EachIn support.
ObjectEnumerator Method implements EachIn support.
remove Remove the first node with a given key.
removeall Remove all the nodes with a given key.
removeallnodes Remove all the nodes with a given key.
removenode Remove a specific node from the hash table.
resize Set table size.
setsize Set table size.
size Get the size of the hash table.
Functions Summary
Create Create a new hash table.
Method bucket:TList(index%)
ReturnsA TList containing the objects of the nodes in a bucket.
DescriptionGet the contents of the bucket at some index as objects.
Method checkfill%()
ReturnsThe number of buckets occupied by at least one element.
DescriptionDetermine the number of buckets occupied by at least one element.
Method clear()
DescriptionClear the contents of the hash table.
Method copy:HashTable()
ReturnsA new hash table with the same properties and containing the same key and value pairs as this one.
DescriptionCreate a copy of the hash table.
Method count%()
ReturnsThe number of elements in the hash table.
DescriptionDetermine the number of elements in the hash table.
Method find:Object(key$,bringtofront%=-1)
ReturnsThe first object associated with a key.
DescriptionGet the first object associated with a key.
Method findall:TList(key$)
ReturnsA TList of all the objects associated with a key.
DescriptionGet all the objects associated with a key.
Method findallnodes:TList(key$)
ReturnsA TList of all the nodes with a key.
DescriptionGet all the nodes with a key.
Method findnode:HashNode(key$,bringtofront%=-1)
ReturnsThe first node with a key.
DescriptionGet the first node with a key.
Method insert:HashNode(key$,value:Object)
ReturnsThe new node.
DescriptionInsert a key and value pair into the hash table.
Method insertnode(n:HashNode)
DescriptionInsert a node into the hash table.
Method KeyEnumerator:HashEnum()
ReturnsAn iterator object.
DescriptionMethod implements EachIn support.
InformationIterates through the keys in the hash table (considers duplicates as they crop up)
Method maxbucket%()
ReturnsThe index of the bucket which contains the greatest number of elements.
DescriptionFind the bucket with the greatest number of elements.
Method maxbucketdepth%()
ReturnsThe greatest number of elements in a single bucket.
DescriptionFind the greatest number of elements contained in a single bucket.
Method NodeEnumerator:HashNodeEnum()
ReturnsAn iterator object.
DescriptionMethod implements EachIn support.
InformationIterates through the nodes in the hash table.
Method ObjectEnumerator:HashEnum()
ReturnsAn iterator object.
DescriptionMethod implements EachIn support.
InformationIterates through the objects in the hash table.
Method remove:HashNode(key$)
ReturnsThe node that was removed.
DescriptionRemove the first node with a given key.
Method removeall%(key$)
ReturnsThe number of nodes that were removed.
DescriptionRemove all the nodes with a given key.
Method removeallnodes:TList(key$)
ReturnsA TList containing the nodes that were removed.
DescriptionRemove all the nodes with a given key.
Method removenode%(n:HashNode)
Returns1 if the node was successfully removed, 0 if something went wrong.
DescriptionRemove a specific node from the hash table.
Method resize(size%)
DescriptionSet table size.
InformationWill retain the elements which already exist in the table.
Method setsize(size%)
DescriptionSet table size.
InformationWill delete any existing elements in the table.
Method size%()
ReturnsThe size of the hash table.
DescriptionGet the size of the hash table.
Function Create:HashTable(size%,hashfunc%(key$)=dbgHashKey)
ReturnsA new hash table.
DescriptionCreate a new hash table.

Module Information

Version1.00
AuthorSophie Kirschner : meapineapple@gmail.com
LicenseCreative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Modserverpine