View Source jhn_t_tree (jhn_stdlib v5.0.6)

Implements T-trees extended with an notion of least upp and greatest lower bounds. For more information on T-Trees see: A Study of Index Structures for Main Memory Database Management Systems. by Tobin J. Lehman and Michael J. Carey, VLDB 1986.

Summary

Functions

The Value is saved under the Index in the Tree, if that index is present the value associated with the index is replaced by Value. add(Index, Value, Tree) is equivalent to add(Index, Value, Tree, nocheck).

The Value is saved under the Index in the Tree, the Flag determines what should happen if that index already has a value associated with in the Tree. If the flag is check an exception is generated and if nocheck the value is replaced.

For each {Index, Value} pair in Pairs the value is stored under the index in the Tree. The adds(Pairs, Tree) call is equivalent to adds(Pairs, Tree, nocheck).

For each {Index, Value} pair in Pairs the value is stored under the index in the Tree. If an index already has a value associated with in the Tree the flag determines what happens. If the flag is check an exception is generated if a index has a value associated with it, if the flag is nocheck the values will be replaced.

If a value is associated the Index the Tree returned has that association removed. The call delete(Index, Tree) is equivalent to delete(Index, Tree, nocheck).

If a value is associated the Index the Tree returned has that association removed. If there is no value associated with the Index in the Tree the flag determines what happens. If the flag is check an exception is generated if no association exists, if the flag is nocheck the unchanged tree is returned.

A tree that has all the associations for the indices removed. The call deletes(Indces, Tree) is equivalent to deletes(Indces, Tree, nocheck).

A tree that has all the associations for the indices removed. If there is no value associated with any of the Indices in the Tree, the flag determines what happens. If the flag is check an exception is generated if, if the flag is nocheck a tree is returned with the other associations removed.

Returns the value associated with Index in the Tree or undefined if no such association exists. The call find(Index, Tree) is equivalent to find(Index, Tree, undefined).

Returns the value associated with Index in the Tree or Default if no such association exists.

Returns the value of the smallest index in the Tree or undefined if the tree is empty. The call first(Tree) if equivalent to first(Tree, undefined).

Returns the value of the smallest index in the Tree or Default if the tree is empty.

For each {Index, Value} pair in Pairs the value is stored under the index in the Tree. Equivalent to from_list(Pairs, []).

Returns the value of the largest index that is less or equal to to Index that has a value associated with it, or undefined if no such index exists. The call greatest_lower_bound(Index, Tree) is equivalent to greatest_lower_bound(Index, Tree, undefined).

Returns the value of the largest index that is less or equal to to Index that has a value associated with it, or Default if no such index exists.

Returns all the indices in ascending order.

Returns true if the Tree is empty, false otherwise.

Returns true if X is a t_tree, false otherwise.

Returns the value of the largest index in the Tree or undefined if the tree is empty. The call last(Tree) if equivalent to last(Tree, undefined).

Returns the value of the largest index in the Tree or Default if the tree is empty.

Returns the value of the smallest index that is greater or equal to to Index that has a value associated with it, or undefined if no such index exists. The call least_upper_bound(Index, Tree) is equivalent to least_upper_bound(Index, Tree, undefined).

Returns the value of the smallest index that is greater or equal to to Index that has a value associated with it, or Default if no such index exists.

Returns true if there is a value associated with Index in the tree, otherwise false.

Creates an empty T-tree. The call new() is equivalent to new([]).

Creates an empty T-tree with min and max internal size according to the options.

Replaces any existing value associated with Index in the tree, otherwise adds a association for the value with the Index. The call replace(Index, Value, Tree) is equivalent to replace(Index, Value, Tree, nocheck).

Replaces any existing value associated with Index in the tree, otherwise the flag determines what happens. If the flag is check an exception is generated, otherwise the value is added.

From a T-tree a list of {Index, Value} pairs.

Returns all the values in ascending order of their indeces.

Types

-type default() :: _.
-type flag() :: check | nocheck.
-type index() :: _.
-type opt() :: {min, pos_integer()} | {max, pos_integer()}.
-opaque t_tree()
-type value() :: _.

Functions

-spec add(index(), value(), t_tree()) -> t_tree().

The Value is saved under the Index in the Tree, if that index is present the value associated with the index is replaced by Value. add(Index, Value, Tree) is equivalent to add(Index, Value, Tree, nocheck).

Link to this function

add(Index, Value, Tree, Flag)

View Source
-spec add(index(), value(), t_tree(), flag()) -> t_tree().

The Value is saved under the Index in the Tree, the Flag determines what should happen if that index already has a value associated with in the Tree. If the flag is check an exception is generated and if nocheck the value is replaced.

-spec adds([{index(), value()}], t_tree()) -> t_tree().

For each {Index, Value} pair in Pairs the value is stored under the index in the Tree. The adds(Pairs, Tree) call is equivalent to adds(Pairs, Tree, nocheck).

-spec adds([{index(), value()}], t_tree(), flag()) -> t_tree().

For each {Index, Value} pair in Pairs the value is stored under the index in the Tree. If an index already has a value associated with in the Tree the flag determines what happens. If the flag is check an exception is generated if a index has a value associated with it, if the flag is nocheck the values will be replaced.

-spec delete(index(), t_tree()) -> t_tree().

If a value is associated the Index the Tree returned has that association removed. The call delete(Index, Tree) is equivalent to delete(Index, Tree, nocheck).

Link to this function

delete(Index, Tree, Flag)

View Source
-spec delete(index(), t_tree(), flag()) -> t_tree().

If a value is associated the Index the Tree returned has that association removed. If there is no value associated with the Index in the Tree the flag determines what happens. If the flag is check an exception is generated if no association exists, if the flag is nocheck the unchanged tree is returned.

-spec deletes([index()], t_tree()) -> t_tree().

A tree that has all the associations for the indices removed. The call deletes(Indces, Tree) is equivalent to deletes(Indces, Tree, nocheck).

Link to this function

deletes(Indices, Tree, _)

View Source
-spec deletes([index()], t_tree(), flag()) -> t_tree().

A tree that has all the associations for the indices removed. If there is no value associated with any of the Indices in the Tree, the flag determines what happens. If the flag is check an exception is generated if, if the flag is nocheck a tree is returned with the other associations removed.

-spec find(index(), t_tree()) -> value() | undefined.

Returns the value associated with Index in the Tree or undefined if no such association exists. The call find(Index, Tree) is equivalent to find(Index, Tree, undefined).

Link to this function

find(Index, T_tree, Default)

View Source
-spec find(index(), t_tree(), default()) -> value() | default().

Returns the value associated with Index in the Tree or Default if no such association exists.

-spec first(t_tree()) -> value() | undefined.

Returns the value of the smallest index in the Tree or undefined if the tree is empty. The call first(Tree) if equivalent to first(Tree, undefined).

-spec first(t_tree(), default()) -> value() | default().

Returns the value of the smallest index in the Tree or Default if the tree is empty.

-spec from_list([{index(), value()}]) -> t_tree().

For each {Index, Value} pair in Pairs the value is stored under the index in the Tree. Equivalent to from_list(Pairs, []).

Link to this function

greatest_lower_bound(Index, Tree)

View Source
-spec greatest_lower_bound(index(), t_tree()) -> value() | undefined.

Returns the value of the largest index that is less or equal to to Index that has a value associated with it, or undefined if no such index exists. The call greatest_lower_bound(Index, Tree) is equivalent to greatest_lower_bound(Index, Tree, undefined).

Link to this function

greatest_lower_bound(Index, T_tree, Default)

View Source
-spec greatest_lower_bound(index(), t_tree(), default()) -> value() | default().

Returns the value of the largest index that is less or equal to to Index that has a value associated with it, or Default if no such index exists.

-spec indices(t_tree()) -> [index()].

Returns all the indices in ascending order.

-spec is_empty(_) -> boolean().

Returns true if the Tree is empty, false otherwise.

-spec is_t_tree(_) -> boolean().

Returns true if X is a t_tree, false otherwise.

-spec last(t_tree()) -> value() | undefined.

Returns the value of the largest index in the Tree or undefined if the tree is empty. The call last(Tree) if equivalent to last(Tree, undefined).

-spec last(t_tree(), default()) -> value() | default().

Returns the value of the largest index in the Tree or Default if the tree is empty.

Link to this function

least_upper_bound(Index, Tree)

View Source
-spec least_upper_bound(index(), t_tree()) -> value() | undefined.

Returns the value of the smallest index that is greater or equal to to Index that has a value associated with it, or undefined if no such index exists. The call least_upper_bound(Index, Tree) is equivalent to least_upper_bound(Index, Tree, undefined).

Link to this function

least_upper_bound(Index, T_tree, Default)

View Source
-spec least_upper_bound(index(), t_tree(), default()) -> value() | default().

Returns the value of the smallest index that is greater or equal to to Index that has a value associated with it, or Default if no such index exists.

-spec member(index(), t_tree()) -> boolean().

Returns true if there is a value associated with Index in the tree, otherwise false.

-spec new() -> t_tree().

Creates an empty T-tree. The call new() is equivalent to new([]).

-spec new([opt()]) -> t_tree().

Creates an empty T-tree with min and max internal size according to the options.

Link to this function

replace(Index, Value, Tree)

View Source
-spec replace(index(), value(), t_tree()) -> t_tree().

Replaces any existing value associated with Index in the tree, otherwise adds a association for the value with the Index. The call replace(Index, Value, Tree) is equivalent to replace(Index, Value, Tree, nocheck).

Link to this function

replace(Index, Value, Tree, _)

View Source
-spec replace(index(), value(), t_tree(), flag()) -> t_tree().

Replaces any existing value associated with Index in the tree, otherwise the flag determines what happens. If the flag is check an exception is generated, otherwise the value is added.

-spec to_list(t_tree()) -> [{index(), value()}].

From a T-tree a list of {Index, Value} pairs.

-spec values(t_tree()) -> [index()].

Returns all the values in ascending order of their indeces.