HasNext returns true if there are more integers to iterate over
()
| 783 | |
| 784 | // HasNext returns true if there are more integers to iterate over |
| 785 | func (iui *unsetIterator) HasNext() bool { |
| 786 | // Skip containers that have no unset bits in our range |
| 787 | for iui.nextKey < 65536 && uint64(iui.nextKey)<<16 < iui.end { |
| 788 | if iui.iter == nil { |
| 789 | // We're in an empty container gap, which has unset bits |
| 790 | if uint64(iui.nextKey)<<16|uint64(iui.emptyContainerVal) < iui.end { |
| 791 | return true |
| 792 | } |
| 793 | // Move to next container |
| 794 | iui.nextKey++ |
| 795 | iui.containerIndex++ |
| 796 | iui.init() |
| 797 | continue |
| 798 | } |
| 799 | if iui.iter.hasNext() { |
| 800 | // Check if next value is within range |
| 801 | nextVal := (uint64(iui.nextKey) << 16) | uint64(iui.iter.peekNext()) |
| 802 | if nextVal < iui.end { |
| 803 | return true |
| 804 | } |
| 805 | } |
| 806 | // Current container has no more unset bits in range, move to next |
| 807 | iui.nextKey++ |
| 808 | iui.containerIndex++ |
| 809 | iui.init() |
| 810 | } |
| 811 | return false |
| 812 | } |
| 813 | |
| 814 | func (iui *unsetIterator) init() { |
| 815 | // Check if we've gone past the end range |
no test coverage detected