goglue / radix

Go library implementing radix tree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

radix

Build Status GoDoc Coverage Status

** Under development **

Abstraction

This library implements Radix Tree in go, the usages for this library can vary as it accepts interfaces as node item

Installation

$ go get github.com/goglue/radix

How to use

import "github.com/goglue/radix"

func main() {
    tree := radix.NewTree()
    tree.Add("someStringConsideredAsPath", 101)
    tree.Add("someStringConsideredAsPath1", 102)
    tree.Add("someStringConsideredAsPath2", 103)
    
    value, err := tree.Get("someStringConsideredAsPath2")
    if nil != err {
        // check error types at the end of the document
    }
    
    val := value.(int)
    println(val) // will output 102
}

Error types

  • ErrNodeNotFound: Returned when passing a path and it could not be found
  • ErrDuplicateNode: Returned when trying to overwrite a path value
  • ErrNodeLabel: Returned when a label is not passed for the node
  • ErrNodeValue: Returned when trying to define a path with a nil value

What is missing

  • Delete
  • Replace/Update

About

Go library implementing radix tree

License:MIT License


Languages

Language:Go 100.0%