@Override
			public AddressRange next() {
				if (nextStartAddress == null) {
					return null;
				}

				long available = end.subtract(nextStartAddress) + 1; // +1 to be inclusive

				int size = chunkSize;
				if (available >= 0 && available < chunkSize) {
					size = (int) available;
				}

				Address currentStart = nextStartAddress;
				Address currentEnd = nextStartAddress.add(size - 1); // -1 since inclusive
				if (currentEnd.compareTo(end) == 0) {
					nextStartAddress = null; // no more
				}
				else {
					nextStartAddress = currentEnd.add(1);
				}

				return new AddressRangeImpl(currentStart, currentEnd);
			}
A class to break a range of addresses into 'chunks' of a give size. This is useful to break-up
processing of large swaths of addresses, such as when performing work in a background thread.
Doing this allows the client to iterator over the range, pausing enough to allow the UI to
update.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/AddressRangeChunker.java