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

github.com/bradhe/trie

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bradhe/trie

  • v0.0.0-20151009193605-934697ba6a14
  • Source
  • Go
  • Socket score

Version published
Created
Source

Trie

This is a quick and dirty implementation of a Trie. It supports a few operations, namely Prefix, Range, and Lookup. It's best intended for when you have a large list of strings that you need to efficiently search through.

Usage

package main

import (
  "github.com/bradhe/trie"
)

func main() {
  t := trie.New()
  t.Insert([]byte("test1"), "First Object")
  t.Insert([]byte("test2"), "Second Object")
  t.Insert([]byte("test3"), "Third Object")

  // Get a single object.
  _ = t.Lookup([]byte("test1"))

  // Get a range of objects.
  _ = t.Range([]byte("test2"), []byte("test3"))

  // Get all objects that have a prefix.
  _ = t.Prefix([]byte("test"))
}

Suggested Improvements

A few ways that this implementation could be more efficient:

  1. Sort the list of child nodes to make lookups slightly faster.
  2. More benchmarks comparing it to other methodologies.

FAQs

Package last updated on 09 Oct 2015

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