New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/maknahar/trie

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/maknahar/trie

  • v0.0.0-20180120150226-dbb4edc78bb3
  • Source
  • Go
  • Socket score

Version published
Created
Source

Trie

Go Implementation of a Thread Safe Trie Data Structure and (some of) Trie Operations

trie := New().Insert("foo", "bar", "baz")

trie.PrefixSearch("fo")                 // returns true
trie.PrefixSearch("fb")                 // returns false
trie.Search("fo")                       // returns false
trie.Search("foo")                      // returns true

Code documentation can be found here.

Supported Operation

Operations on Trie Data Structure Level

  • New() *Trie

    Creates an initialized trie data structure

  • Insert(keywords ...string)

    Insert allow one or more keyword to be inserted in trie. keyword can be any valid Unicode string

  • PrefixSearch(Key string) (found bool)

    Search checks if keyword exist in trie as a keyword or prefix to keyword

  • Search(keyword string) (found bool)

    PrefixSearch checks if keyword exist in trie as a fully qualified keyword.

  • Delete(keyword string)

    Delete deletes a keyword from a trie if keyword exist in trie

  • DeleteBranch(key string)

    DeleteBranch deletes all child after last letter of key if key exists in trie. If key is found, key will be treated as a keyword after this operation

Operations on Node Level

  • CreateNode(v rune) *Node

    CreateNode returns an initialized trie node

  • AddChildNode(v rune) *Node

    AddChildNode add child node to current node with value v

  • Len() int

    Len returns the number of children for node

  • IsLeafNode() bool

    IsLeafNode returns true if current node is a leaf node in Trie

  • GetChildNode(v rune) (node *Node, exist bool)

    GetChildNode retrieve child node with value v.

  • DeleteChildNode(v rune)

    DeleteChildNode Deletes the child node if it exist

Your ideas and suggestions are always welcome. Either in form of issues or Pull Requests.

FAQs

Package last updated on 20 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc