diff options
Diffstat (limited to 'vendor/github.com/toqueteos/trie')
-rw-r--r-- | vendor/github.com/toqueteos/trie/LICENSE.txt | 22 | ||||
-rw-r--r-- | vendor/github.com/toqueteos/trie/README.md | 7 | ||||
-rw-r--r-- | vendor/github.com/toqueteos/trie/go.mod | 1 | ||||
-rw-r--r-- | vendor/github.com/toqueteos/trie/trie.go | 102 |
4 files changed, 0 insertions, 132 deletions
diff --git a/vendor/github.com/toqueteos/trie/LICENSE.txt b/vendor/github.com/toqueteos/trie/LICENSE.txt deleted file mode 100644 index 8a21d84038..0000000000 --- a/vendor/github.com/toqueteos/trie/LICENSE.txt +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2013 Caleb Spare
-
-MIT License
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/toqueteos/trie/README.md b/vendor/github.com/toqueteos/trie/README.md deleted file mode 100644 index 3372521de4..0000000000 --- a/vendor/github.com/toqueteos/trie/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Trie - -[![GoDoc](http://godoc.org/github.com/toqueteos/trie?status.png)](http://godoc.org/github.com/toqueteos/trie) - -This is a fork of https://github.com/cespare/go-trie that adds the `PrefixIndex` method. - -It's required for https://github.com/toqueteos/substring. diff --git a/vendor/github.com/toqueteos/trie/go.mod b/vendor/github.com/toqueteos/trie/go.mod deleted file mode 100644 index 24f2eb5fe7..0000000000 --- a/vendor/github.com/toqueteos/trie/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/toqueteos/trie diff --git a/vendor/github.com/toqueteos/trie/trie.go b/vendor/github.com/toqueteos/trie/trie.go deleted file mode 100644 index 4411f3e429..0000000000 --- a/vendor/github.com/toqueteos/trie/trie.go +++ /dev/null @@ -1,102 +0,0 @@ -// Package trie is an implementation of a trie (prefix tree) data structure over byte slices. It provides a -// small and simple API for usage as a set as well as a 'Node' API for walking the trie. -package trie - -// A Trie is a a prefix tree. -type Trie struct { - root *Node -} - -// New construct a new, empty Trie ready for use. -func New() *Trie { - return &Trie{ - root: &Node{}, - } -} - -// Insert puts b into the Trie. It returns true if the element was not previously in t. -func (t *Trie) Insert(b []byte) bool { - n := t.root - for _, c := range b { - next, ok := n.Walk(c) - if !ok { - next = &Node{} - n.branches[c] = next - n.hasChildren = true - } - n = next - } - if n.terminal { - return false - } - n.terminal = true - return true -} - -// Contains checks t for membership of b. -func (t *Trie) Contains(b []byte) bool { - n := t.root - for _, c := range b { - next, ok := n.Walk(c) - if !ok { - return false - } - n = next - } - return n.terminal -} - -// PrefixIndex walks through `b` until a prefix is found (terminal node) or it is exhausted. -func (t *Trie) PrefixIndex(b []byte) int { - var idx int - n := t.root - for _, c := range b { - next, ok := n.Walk(c) - if !ok { - return -1 - } - if next.terminal { - return idx - } - n = next - idx++ - } - if !n.terminal { - idx = -1 - } - return idx -} - -// Root returns the root node of a Trie. A valid Trie (i.e., constructed with New), always has a non-nil root -// node. -func (t *Trie) Root() *Node { - return t.root -} - -// A Node represents a logical vertex in the trie structure. -type Node struct { - branches [256]*Node - terminal bool - hasChildren bool -} - -// Walk returns the node reached along edge c, if one exists. The ok value indicates whether such a node -// exist. -func (n *Node) Walk(c byte) (next *Node, ok bool) { - next = n.branches[int(c)] - return next, (next != nil) -} - -// Terminal indicates whether n is terminal in the trie (that is, whether the path from the root to n -// represents an element in the set). For instance, if the root node is terminal, then []byte{} is in the -// trie. -func (n *Node) Terminal() bool { - return n.terminal -} - -// Leaf indicates whether n is a leaf node in the trie (that is, whether it has children). A leaf node must be -// terminal (else it would not exist). Logically, if n is a leaf node then the []byte represented by the path -// from the root to n is not a proper prefix of any element of the trie. -func (n *Node) Leaf() bool { - return !n.hasChildren -} |