diff options
author | Alberto Cortés <alcortesm@gmail.com> | 2017-01-30 21:34:33 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-01-30 21:34:33 +0100 |
commit | e80d7b7267ba9f2057f259be331c4de927a60ecb (patch) | |
tree | 7d7d6917576596d76c4be78ca099e039552ae4e0 /plumbing/difftree/internal/merkletrie/node.go | |
parent | 90c1bbd07862c6e1c3ce80306d69eee8ed277056 (diff) | |
download | go-git-e80d7b7267ba9f2057f259be331c4de927a60ecb.tar.gz |
delete old noder, create a new one in utils (#241)
Diffstat (limited to 'plumbing/difftree/internal/merkletrie/node.go')
-rw-r--r-- | plumbing/difftree/internal/merkletrie/node.go | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/plumbing/difftree/internal/merkletrie/node.go b/plumbing/difftree/internal/merkletrie/node.go deleted file mode 100644 index 99be5b8..0000000 --- a/plumbing/difftree/internal/merkletrie/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 -} |