Skip to content

Commit

Permalink
Stop increasing the nextIndex beyond endIndex in BagIterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
andersio committed Nov 27, 2016
1 parent 30abe6f commit 439f535
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Bag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public struct BagIterator<Element>: IteratorProtocol {

public mutating func next() -> Element? {
let currentIndex = nextIndex
nextIndex = currentIndex + 1

if currentIndex < endIndex {
nextIndex = currentIndex + 1
return base[currentIndex].value
}

Expand Down

0 comments on commit 439f535

Please sign in to comment.