YAP 7.1.0
Backtrackable Hash Tables

More...

Detailed Description

This library implements hash-tables, that associate keys with values It requires the hash key to be any ground term, but the value term can take any value

The library can be loaded as

:- use_module( library( bhash ) )

The library's code uses backtrackable updates and an array to store the terms Implicit keys are generated by term_hash/4 (note that we cannot guarantee there will be no collisions)


Class Documentation

◆ is_b_hash/1

class is_b_hash/1

is_b_hash( +Hash )

True if term Hash is a hash table

◆ b_hash_new/1

class b_hash_new/1

b_hash_new( -NewHash )

Create a empty hash table NewHash, with size obtained from array__default_size/1 , by default 2048 entries

◆ b_hash_new/2

class b_hash_new/2

b_hash_new( -_NewHash_, +_Size_ )

Create a empty hash table, with size Size entries

◆ b_hash_new/4

class b_hash_new/4

b_hash_new( -_NewHash_, +_Size_, :Hash, :Cmp )

Create a empty hash table, with size Size entries Hash defines a partition function, and Cmp defined a comparison function

◆ b_hash_size/2

class b_hash_size/2

b_hash_size( +_Hash_, -_Size_ )

Size unifies with the size of the hash table Hash

◆ b_hash_lookup/3

class b_hash_lookup/3

b_hash_lookup( +_Key_, ?_Val_, +_Hash_ )

Search the ground term Key in table Hash and unify Val with the associated entry

◆ b_hash_update/3

class b_hash_update/3

b_hash_update( +_Key_, +_Hash_, +NewVal )

Update to the value associated with the ground term Key in table Hash to NewVal

◆ b_hash_update/4

class b_hash_update/4

b_hash_update( +_Key_, -_OldVal_, +_Hash_, +NewVal )

Update to the value associated with the ground term Key in table Hash to NewVal, and unify OldVal with the current value

◆ b_hash_insert_new/4

class b_hash_insert_new/4

b_hash_insert_new(+_Hash_, +_Key_, Val, +_NewHash_ )

Insert the term Key-_Val_ in table Hash and unify NewHash with the result If ground term Key exists, fail

◆ b_hash_to_list/2

class b_hash_to_list/2

b_hash_to_list(+_Hash_, -_KeyValList_ )

The term KeyValList unifies with a list containing all terms Key-_Val_ in the hash table

◆ b_key_to_list/2

class b_key_to_list/2

b_key_to_list(+_Hash_, -_KeyList_ )

b_key_to_list(+_Hash_, -_ValList_ )

The term KeyList unifies with a list containing all keys in the hash table

The term _`valList_ unifies with a list containing all values in the hash table