ClosedIntervals.Tree (closed_intervals v0.6.0) View Source

Functions to manipulate a tree of closed intervals.

Library users will often use the ClosedIntervals struct, which contains a tree together with matching order and equality comparison functions. This module contains utilities for direct manipulations on the tree structure, many of which are reexported in ClosedIntervals.

Link to this section Summary

Link to this section Types

Specs

comparison() :: :lt | :eq | :gt

Specs

t(data) ::
  {:tree, left :: nil | t(data), right :: nil | t(data), left_bound :: data,
   right_bound :: data, cut :: nil | data}

Link to this section Functions

Construct a tree from a sorted list of data.

See ClosedIntervals.from/2.

Specs

from_bounds({data, data}) :: t(data) when data: var

Create a tree with two leaves from the left and right bounds.

Link to this function

from_leaf_intervals(leafs)

View Source

See ClosedIntervals.from_leaf_intervals/1.

Link to this function

get_all_intervals(tree, value, eq, order)

View Source

See ClosedIntervals.get_all_intervals/2.

Link to this function

get_all_intervals_by(tree, navigation)

View Source

Specs

get_all_intervals_by(t(data), (data -> comparison())) :: [
  ClosedIntervals.interval(data)
]
when data: var

Get all intervals to which the given navigation function return :eq.

The function navigation/1 says whether a given position is less than, greater than, or equal to the desired position.

See ClosedIntervals.leaf_intervals/1.

See ClosedIntervals.left_bound/1.

Specs

map(t(data1), (data1 -> data2)) :: t(data2) when data1: var, data2: var

See ClosedIntervals.map/2.

See ClosedIntervals.right_bound/1.

See ClosedIntervals.to_list/1.

Link to this macro

tree(args \\ [])

View Source (macro)

This is the internal tree representation. It is not intended to be used publicly.

Link to this macro

tree(record, args)

View Source (macro)