diff --git a/README.md b/README.md index e3e3fef..4f0fdff 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ import ( ) func main() { + // Create an array list al := list.NewArrayList() al.Add(5, 6, 7) diff --git a/btree/btree.go b/btree/btree.go index 213a7cb..4442a54 100644 --- a/btree/btree.go +++ b/btree/btree.go @@ -612,6 +612,7 @@ func (n *node) iterate(dir direction, start, stop interface{}, includeStart bool } } if len(n.children) > 0 { + if hit, ok = n.children[i+1].iterate(dir, start, stop, includeStart, hit, iter, cmp); !ok { return hit, false } @@ -620,7 +621,7 @@ func (n *node) iterate(dir direction, start, stop interface{}, includeStart bool return hit, false // continue } hit = true - if !iter(n.items[i]) { + if !iter(n.items[i] ) { return hit, false } } @@ -634,7 +635,6 @@ func (n *node) iterate(dir direction, start, stop interface{}, includeStart bool } // Used for testing/debugging purposes. -//nolint func (n *node) print(w io.Writer, level int) { fmt.Fprintf(w, "%sNODE:%v\n", strings.Repeat(" ", level), n.items) for _, c := range n.children { diff --git a/map/linkedmap/linkedmap.go b/map/linkedmap/linkedmap.go index b1d42ae..23ac04c 100644 --- a/map/linkedmap/linkedmap.go +++ b/map/linkedmap/linkedmap.go @@ -106,12 +106,16 @@ func (lm *linkedMap) Size() int { } func (lm *linkedMap) IsEmpty() bool { - return lm.Size() == 0 + return lm.Size() == 0 } func (lm *linkedMap) Put(k, v interface{}) interface{} { var retVal interface{} = nil if oldElement, ok := lm.data[k]; ok { + + + + retVal = oldElement.value oldElement.value = v // move the element to the end of the list diff --git a/stack/stack.go b/stack/stack.go index 1eec3d4..bca5640 100644 --- a/stack/stack.go +++ b/stack/stack.go @@ -50,7 +50,6 @@ func (s *stack) Pop() interface{} { val, _ := s.l.Get(size - 1) if _, err := s.l.Remove(size - 1); err != nil { //todo: what should we do if failing to remove the element? - return nil } return val