Skip to main content

internal/BTreeHelper

Reference for mo:core/internal/BTreeHelper in the core library.

This is an implementation support module for B+tree operations. It is public for reuse inside core and tests, but it is not a stable application-facing API; prefer pure/BMap or mutable/MBMap unless you are working on the map implementation itself.

Import

mo:core/internal/BTreeHelper

Status

  • Internal module

Public API

Types

  • DeletionSide

Functions

insertAtPosition<T>(array : [var ?T], insertElement : ?T, insertIndex : Nat, currentLastElementIndex : Nat)

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

insertOneAtIndexAndSplitArray<T>(array : [var ?T], insertElement : T, insertIndex : Nat) : ([var ?T], T, [var ?T])

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

splitArrayAndInsertTwo<T>(children : [var ?T], rebalancedChildIndex : Nat, leftChildInsert : T, rightChildInsert : T) : ([var ?T], [var ?T])

Implements the splitArrayAndInsertTwo helper described by its signature and contract.

Use when: code or specifications need this operation with the documented contract.

deleteAndShift<T>(array : [var ?T], deleteIndex : Nat) : T

Returns the updated collection or value described by the contract.

Use when: the postcondition must relate the updated value to the previous one.

replaceTwoWithElementAndShift<T>(array : [var ?T], element : T, replaceIndex : Nat)

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

insertAtPostionAndDeleteAtPosition<T>(array : [var ?T], insertElement : ?T, insertIndex : Nat, deleteIndex : Nat) : T

Returns or applies the corresponding update to the structure.

Use when: the postcondition must relate the updated value to the previous one.

mergeParentWithChildrenAndDelete<T>(parentElement : ?T, childCount : Nat, leftChild : [var ?T], rightChild : [var ?T], deleteIndex : Nat, deletionSide : DeletionSide) : ([var ?T], T)

Implements the mergeParentWithChildrenAndDelete helper described by its signature and contract.

Use when: code or specifications need this operation with the documented contract.

Summary

  • Internal module under mo:core/internal/BTreeHelper.
  • Exposes 7 public functions.