All Downloads are FREE. Search and download functionalities are using the official Maven repository.

inet.ipaddr.format.SpliteratorBase Maven / Gradle / Ivy

There is a newer version: 5.5.1
Show newest version
package inet.ipaddr.format;

import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.function.Consumer;

import inet.ipaddr.format.util.AddressComponentRangeSpliterator;

/**
 * SpliteratorBase provides the iterating functionality for the spliterators in this library.
 * 

* * @author seancfoley * */ abstract class SpliteratorBase implements AddressComponentRangeSpliterator { protected long iteratedCountL; protected boolean inForEach; boolean tryAdvance(Iterator iterator, Consumer action) { T next; try { next = iterator.next(); iteratedCountL++; } catch(NoSuchElementException e) { // note: should never reach here thanks to bounds checking return false; } action.accept(next); return true; } void forEachRemaining(Iterator iterator, Consumer action, long bound) { while(iteratedCountL < bound) { T next; try { next = iterator.next(); iteratedCountL++; } catch(NoSuchElementException e) { // note: should never reach here thanks to bounds checking return; } action.accept(next); } } @Override public int characteristics() { return CONCURRENT | NONNULL | SORTED | ORDERED | DISTINCT | SIZED | SUBSIZED; } @Override public String toString() { return "spliterator for " + getAddressItem(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy