Skip to content

Instantly share code, notes, and snippets.

@pacuna
Last active June 15, 2020 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacuna/6b462db6d66a01c7f53d3ab8e74a129e to your computer and use it in GitHub Desktop.
Save pacuna/6b462db6d66a01c7f53d3ab8e74a129e to your computer and use it in GitHub Desktop.
func (l *list) Add(item []byte) bool {
var pred, curr *node
key, _ := hashstructure.Hash(item, nil)
pred = l.head
curr = pred.next
for curr.key < key {
pred = curr
curr = curr.next
}
if key == curr.key {
return false
}
n := newNode(item)
n.next = curr
pred.next = n
l.size++
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment