vcaesar / cedar

Go efficiently double-array trie and aho corasick

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cedar

Build Status Build Status CircleCI Status codecov Go Report Card GoDoc Release

Package cedar implementes double-array trie and aho corasick

It is implements the cedar and paper by golang.

Install

go get -u github.com/vcaesar/cedar

Usage

package main

import (
	"fmt"

	"github.com/vcaesar/cedar"
)

func main() {
	// Create a new cedar trie.
	d := cedar.New()
	d.Insert([]byte("ab"), 1)
	d.Insert([]byte("abc"), 2)
	d.Insert([]byte("abcd"), 3)

	fmt.Println(d.Jump([]byte("ab"), 0))
	fmt.Println(d.Find([]byte("bc"), 0))

	fmt.Println(d.PrefixMatch([]byte("bc"), 0))
	fmt.Println(d.ExactMatch([]byte("ab")))
}

License

This is released under the BSD-2 license, following the original license of C++ cedar.

Reference

About

Go efficiently double-array trie and aho corasick

License:BSD 2-Clause "Simplified" License


Languages

Language:Go 100.0%