trie

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Implementation is based on https://github.com/dghubble/trie

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PathTrie

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

func New

func New() *PathTrie

New creates a new Trie.

func (*PathTrie) Count

func (t *PathTrie) Count() int

Count returns the total number of nodes.

func (*PathTrie) HasPrefix

func (t *PathTrie) HasPrefix(prefix string) bool

HasPrefix checks if a path with the given prefix exists or could potentially exist in the trie. If trie is 'a/b/c': - 'a/b' - true. - 'a/b/c/d' - true, because we may have 'd' in trie, no collision. - 'a/b/f' - false, we hit a point where missing child node. We need this because if we have in go.mod 'github.com/a/b', we can import 'github.com/a/b/baz' in out code. '/baz' is not in go.mod, part of external package.

func (*PathTrie) Put

func (t *PathTrie) Put(importPath string)

Put inserts a path into the trie structure.

func (*PathTrie) String

func (t *PathTrie) String() string

String returns a human-readable representation of the trie.

Jump to

Keyboard shortcuts

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