stupidb.associative.indextree

Module implementing an abstraction for navigation of array-backed trees.

Functions

first_node(level, *, fanout)

Return the first node at level.

last_node(level, *, fanout)

Return the last node at level.

reprtree(nodes, *, fanout[, indent])

Return a string representation of nodes.

Classes

IndexTree(*, height, fanout)

Abstraction for navigating around array-backed trees.

class stupidb.associative.indextree.IndexTree(*, height, fanout)[source]

Abstraction for navigating around array-backed trees.

first_node(level)[source]

Return the first node at level.

Return type

int

last_node(level)[source]

Return the last node at level.

Return type

int

property leaves: range

Return the indices of the leaves of the tree.

Return type

range

parent(node)[source]

Return the index of the parent node of node.

Return type

int

stupidb.associative.indextree.first_node(level, *, fanout)[source]

Return the first node at level.

Return type

int

stupidb.associative.indextree.last_node(level, *, fanout)[source]

Return the last node at level.

Return type

int

stupidb.associative.indextree.reprtree(nodes, *, fanout, indent='    ')[source]

Return a string representation of nodes.

Parameters
  • nodes (Sequence[+T]) – A sequence of nodes in a tree.

  • fanout (int) – The number of children per node.

  • indent (str) – The prefix number of spaces to print at each level.

Return type

str