phtree

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 2 Imported by: 0

README

phtree

Release Go Report Card Go Reference License

PH-tree (Permutation Hierarchical Tree) implementation in Go.

Features

  • Insertion and search operations for multi-dimensional keys
  • Removal of key-value pairs from the tree
  • Configurable maximum depth of the tree
  • Thread-safe concurrent access to the tree
  • Efficient handling of high-dimensional and sparse data

Installation

Install the phtree package in your Go project by installing it with the following command:

go get github.com/0xnu/phtree

Usage

Here's a basic example of how to use the phtree package:

package main

import (
	"fmt"
	"github.com/0xnu/phtree"
)

func main() {
	tree := phtree.New(phtree.WithMaxDepth(8))

	tree.Insert([]uint64{0, 1, 2}, "apple")
	tree.Insert([]uint64{0, 1, 3}, "banana")

	value := tree.Search([]uint64{0, 1, 2})
	fmt.Println(value) // Output: "apple"

	tree.Remove([]uint64{0, 1, 3})
}

Check out the examples directory for more detailed usage and examples.

Testing

To run the tests for the PH-Tree package, use the following command:

go test

Performance

To run the benchmarking code, you can use the following command:

go run benchmark/benchmark.go

License

This project is licensed under the MIT License.

(c) 2024 Finbarrs Oketunji.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*PHTree)

Option represents an option for configuring the PHTree.

func WithMaxDepth

func WithMaxDepth(maxDepth int) Option

WithMaxDepth sets the maximum depth of the PHTree.

type PHTree

type PHTree struct {
	// contains filtered or unexported fields
}

PHTree represents a Permutation Hierarchical Tree.

func New

func New(opts ...Option) *PHTree

New creates a new PHTree with the specified options.

func (*PHTree) Insert

func (t *PHTree) Insert(key []uint64, value interface{})

Insert inserts a key-value pair into the PHTree.

func (*PHTree) Remove

func (t *PHTree) Remove(key []uint64)

Remove removes a key-value pair from the PHTree.

func (*PHTree) Search

func (t *PHTree) Search(key []uint64) interface{}

Search searches for a key in the PHTree and returns the associated value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL