segment_trie

package
v0.0.0-...-dbb2ee5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package segment_trie provides a trie data structure for storing URL paths. It has the main purpose of checking for path collisions.

The SegmentTrie is a trie data structure that segments paths into tokens. Stored paths can contain the `{*}` and `{**}` operators:

  • operator `{*}` is used to match a single segment in a path, and may include a prefix and/or suffix.
  • operator `{**}` is used any number of segments in a path, and may include a prefix and/or suffix. It must be the last operator in the stored path (this is not validated but is assumed to be true).

During insertion, the trie is first traversed to detect collisions: literal and `{*}` nodes are matched segment by segment, and any `{**}` node checks its stored suffixes against the remaining path, to catch overlapping multi-segment matches. If any path already in the trie can match the new token sequence under these rules, insertion fails with a collision error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	EndNode  bool             `json:"-"`
	Children map[string]*Node `json:"children"`
	Suffixes []string         `json:"suffixes"`
}

type SegmentTrie

type SegmentTrie struct {
	Root *Node
}

func New

func New() *SegmentTrie

func (*SegmentTrie) InsertAndCheckCollisions

func (t *SegmentTrie) InsertAndCheckCollisions(tokens []token.Token) error

Jump to

Keyboard shortcuts

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