fn Treap(comptime Key: type, comptime compareFn: anytype) type

Parameters

Key: type,
compareFn: anytype,

Fields

root: ?*Node = null,
prng: Prng = .{ },

Types

Functions

fn getEntryFor(self: *Self, key: Key) Entry

Lookup the Entry for the given key in the treap. The Entry act’s as a slot in t…

Lookup the Entry for the given key in the treap. The Entry act’s as a slot in the treap to insert/replace/remove the node associated with the key.

fn getEntryForExisting(self: *Self, node: *Node) Entry

Get an entry for a Node that currently exists in the treap. It is undefined beh…

Get an entry for a Node that currently exists in the treap. It is undefined behavior if the Node is not currently inserted in the treap. The Entry act’s as a slot in the treap to insert/replace/remove the node associated with the key.

fn getMax(self: Self) ?*Node

Returns the largest Node by key in the treap if there is one. Use `getEntryForE…

Returns the largest Node by key in the treap if there is one. Use getEntryForExisting() to replace/remove this Node from the treap.

fn getMin(self: Self) ?*Node

Returns the smallest Node by key in the treap if there is one. Use `getEntryFor…

Returns the smallest Node by key in the treap if there is one. Use getEntryForExisting() to replace/remove this Node from the treap.