aboutsummaryrefslogtreecommitdiffstats
path: root/difftree/internal/radixmerkle/node.go
diff options
context:
space:
mode:
authorAlberto Cortés <alcortesm@gmail.com>2016-11-24 15:29:22 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-11-24 15:29:22 +0100
commit8966c042795509ed17730e50d352ad69901c3da8 (patch)
tree3ce51d49f134d440f73f268ecaaf00bffa980e8c /difftree/internal/radixmerkle/node.go
parent81c5d2c6c672509ee7f30a346b890f3920ff20c1 (diff)
downloadgo-git-8966c042795509ed17730e50d352ad69901c3da8.tar.gz
mv difftree/internal/radixmerkle to difftre/internal/merkletrie (#138)
Diffstat (limited to 'difftree/internal/radixmerkle/node.go')
-rw-r--r--difftree/internal/radixmerkle/node.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/difftree/internal/radixmerkle/node.go b/difftree/internal/radixmerkle/node.go
deleted file mode 100644
index 99be5b8..0000000
--- a/difftree/internal/radixmerkle/node.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package merkletrie
-
-import (
- "sort"
- "strings"
-)
-
-// A node is a Noder implementation for testing purposes: It is easier
-// to create test trees using nodes than using real git tree objects.
-type node struct {
- hash []byte
- key string
- children []*node
-}
-
-// newNode returns a new Node with the given hash, key and children
-// (children can be specified in any order).
-func newNode(hash []byte, key string, children []*node) *node {
- sort.Sort(reverseAlphabeticallyByKey(children))
-
- return &node{
- hash: hash,
- key: key,
- children: children,
- }
-}
-
-// Hash returns the hash of the node.
-func (n *node) Hash() []byte {
- return n.hash
-}
-
-// Key returns the key of the node.
-func (n *node) Key() string {
- return n.key
-}
-
-// NumChildren returns the number of children.
-func (n *node) NumChildren() int {
- return len(n.children)
-}
-
-// Children returns the node's children in reverse key alphabetical
-// order.
-func (n *node) Children() []Noder {
- ret := make([]Noder, n.NumChildren())
- for i := range n.children {
- ret[i] = n.children[i]
- }
- return ret
-}
-
-type reverseAlphabeticallyByKey []*node
-
-func (a reverseAlphabeticallyByKey) Len() int {
- return len(a)
-}
-
-func (a reverseAlphabeticallyByKey) Swap(i, j int) {
- a[i], a[j] = a[j], a[i]
-}
-
-func (a reverseAlphabeticallyByKey) Less(i, j int) bool {
- return strings.Compare(a[i].key, a[j].key) > 0
-}