This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/library/tries.yap

106 lines
2.7 KiB
Plaintext
Raw Normal View History

2015-11-18 15:06:25 +00:00
/**
* @file tries.yap
* @author Ricardo Rocha
*
2019-03-03 02:01:39 +00:00
* @brief YAP tries interface
2015-11-18 15:06:25 +00:00
*
*
*/
/****************************************
File: tries.yap
Author: Ricardo Rocha
Comments: Tries module for Yap Prolog
version: $ID$
****************************************/
2015-11-18 15:06:25 +00:00
:- module(tries, [
trie_open/1,
trie_close/1,
trie_close_all/0,
trie_empty/1,
trie_mode/1,
trie_put_entry/3,
trie_check_entry/3,
trie_get_entry/2,
trie_get_first_entry/2,
trie_get_last_entry/2,
trie_traverse/2,
trie_traverse/3,
trie_remove_entry/1,
trie_remove_subtree/1,
trie_join/2,
trie_intersect/2,
trie_count_join/3,
trie_count_intersect/3,
trie_dup/2,
trie_save/2,
trie_load/2,
trie_stats/4,
trie_max_stats/4,
trie_usage/4,
trie_print/1,
open_trie/1,
close_trie/1,
close_all_tries/0,
put_trie_entry/4,
get_trie_entry/3,
remove_trie_entry/1,
print_trie/1,
trie_traverse_mode/1,
trie_disable_hash/0,
trie_enable_hash/0,
trie_traverse_first/2,
trie_traverse_next/2,
trie_to_list/2,
trie_to_depth_breadth_trie/4,
trie_to_depth_breadth_trie/6,
trie_get_depth_breadth_reduction_entry/1,
trie_get_depth_breadth_reduction_opt_level_count/2,
trie_replace_nested_trie/3
]).
2014-09-11 20:06:57 +01:00
2015-11-18 15:06:25 +00:00
/** @defgroup tries Trie DataStructure
2015-01-04 23:58:23 +00:00
@ingroup library
2014-09-11 20:06:57 +01:00
@{
2019-03-03 02:01:39 +00:00
@brief Engine Independent trie library
2014-09-11 20:06:57 +01:00
The next routines provide a set of utilities to create and manipulate
prefix trees of Prolog terms. Tries were originally proposed to
implement tabling in Logic Programming, but can be used for other
purposes. The tries will be stored in the Prolog database and can seen
as alternative to `assert` and `record` family of
primitives. Most of these utilities have been implemented in `C`
for efficiency. They are available through the
`use_module(library(tries))` command.
*/
:- load_foreign_files([tries], [], init_tries).
trie_empty(Trie) :-
trie_usage(Trie, 0, 0, _).
trie_dup(Trie, CopyTrie) :-
trie_open(CopyTrie),
trie_join(CopyTrie, Trie).
trie_traverse(Trie, Ref) :-
trie_traverse(Trie, 0, Ref).
trie_to_depth_breadth_trie(Trie, DepthBreadthTrie, FinalLabel, OptimizationLevel) :-
integer(OptimizationLevel),
trie_dup(Trie, CopyTrie),
trie_open(DepthBreadthTrie),
trie_depth_breadth(CopyTrie, DepthBreadthTrie, FinalLabel, OptimizationLevel, 0, _),
trie_close(CopyTrie).
trie_to_depth_breadth_trie(Trie, DepthBreadthTrie, FinalLabel, OptimizationLevel, StartCounter, EndCounter) :-
trie_depth_breadth(Trie, DepthBreadthTrie, FinalLabel, OptimizationLevel, StartCounter, EndCounter).
2017-04-07 23:10:59 +01:00
%% @}