Skip to content

Commit

Permalink
Modified Append operation for supporting functional programming
Browse files Browse the repository at this point in the history
  • Loading branch information
lrleon committed Mar 20, 2021
1 parent 19bc947 commit 77a609f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions treaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,12 @@ func (tree *Treap) Insert(item interface{}) interface{} {
}

// Append equivalent to insert. Put for supporting functional operations
func (tree *Treap) Append(item interface{}) interface{} {
return tree.Insert(item)
func (tree *Treap) Append(item interface{}, items ...interface{}) *Treap {
tree.Insert(item)
for _, i := range items {
tree.Insert(i)
}
return tree
}

// Helper for inserting node p into the tree root. BST order is handled through less function.
Expand Down

0 comments on commit 77a609f

Please sign in to comment.