congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Iterator.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
java.util.Iterator
constructor

Best Java code snippets using java.util.Iterator.<init> (Showing top 20 results out of 315)

origin: stackoverflow.com

Iterator<Integer> powersOfTwo = new AbstractSequentialIterator<Integer>(1) { // note the initial value!
  protected Integer computeNext(Integer previous) {
   return (previous == 1 << 30) ? null : previous * 2;
  }
 };
origin: stackoverflow.com

 public Iterator<T> iterator(int index) {
  Iterator<T> it = new DoublelinkedlistIterator();
  for (int i = 0; i < index && it.hasNext(); i++, it.next());
  return it;
}
origin: stackoverflow.com

 import org.neo4j.graphdb.*;
import org.neo4j.helpers.Predicate;
import org.neo4j.helpers.collection.FilteringIterator;

...

try (ResourceIterator<Node> nodes = 
  graphDatabaseService.findNodes(DynamicLabel.label("LABEL1"))) {

  Iterator<Node> nodeWithAllLabels = new FilteringIterator<>(nodes,
      node -> node.hasLabel(DynamicLabel.label("LABEL2")) && 
          node.hasLabel(DynamicLabel.label("LABEL3"))
  );

  // do stuff with nodeWithAllLabels
}
origin: stackoverflow.com

 public Iterator<E> iterator(int x){

  Iterator<E> it = new ListIterator();

  for (; x > 0; --x){
    it.next(); 
  }
  return it;
}
origin: stackoverflow.com

 Iterator<Choice> iter = new list.iterator();
while iterator.hasNext(){
  iter.next().add( option );
}
origin: stackoverflow.com

 Iterator<String> di = new MyDoublyIterator<String>(); 
di.hasPrev();
origin: stackoverflow.com

 public Iterator<E> iterator(int x) {
  if (x < 0 || this.size() < x) {
    throw new IndexOutOfBoundsException();
  }

  Iterator<E> it = new ListIterator();

  for (; x > 0; --x) {
    it.next(); // ignore the first x values
  }
  return it;
}
origin: stackoverflow.com

 List<String[]> input = Arrays.asList(
  new String[] {"such", "nice", "question"},
  new String[] {"much", "iterator"},
  new String[] {"very", "wow"}
);
Iterator<Collection<String>> it = new CombinatorIterator(input);
it.forEachRemaining(System.out::println);
origin: stackoverflow.com

 List<String> jedis = asList("Obiwan","Yoda","Luke");
List<String> siths = asList("Lord Sidious", "Darth Mul", "Darth Vader");
List<String> padawans = asList("Anakin", "Jarjar", "Poncho");

Iterator<Triplet> iter = new TripletIterator(jedis, siths, padawans);
while(iter.hasNext()){
  Triplet t = iter.next();
  System.out.println(t);
}
origin: stackoverflow.com

 Iterator<Point> pointIterator = new PointParser();
Spliterator<Point> pointSpliterator = Spliterators.spliteratorUnknownSize(pointIterator, Spliterator.IMMUTABLE | Spliterator.NONNULL);
Set<Point> result = StreamSupport.stream(pointSpliterator, true)
  .filter(this::withinDistance)
  .collect(Collectors.toSet());
origin: stackoverflow.com

 public <T> LinkedList<T> sort(LinkedList<T> list){
  Iterator<T> iter = new list.iterator();
  while (iter.hasNext()){
    T t = iter.next();
    ...
  }
}
origin: stackoverflow.com

public static final Iterator<Integer> RAND_INT_ITER =
 new AbstractIterator<Integer>() {
   @Override
   protected Integer computeNext() {
     return ThreadLocalRandom.current().nextInt();
   }
 };
origin: stackoverflow.com

 final Iterator<Integer> series = new AbstractLinkedIterator<Integer>(100) {

  @Override protected Integer computeNext(final Integer previous) {
    return previous == 80 ? null : previous - 1;
  }
};
while (series.hasNext()) {
  System.out.println(series.next());
}
origin: stackoverflow.com

 Iterator<Long> i = new Counter(0, 50);
while (i.hasNext()) {
  System.out.println(i.next());  // Prints 0 to 50
}
origin: stackoverflow.com

 int i = 0;
Iterator<Kid> it = new ArrayIterator<>(kids);
StringBuffer sb = new StringBuffer();
while (it.hasNext()) {
  Kid kid = it.next();
  if (!kid.hasToy()) continue;
  sb.append(++i).append(".").append(kid.getSurname());
  if (it.hasNext()) {
    sb.append(", ");
  }
}
origin: stackoverflow.com

 List<List<Integer>> elements = Arrays.asList(Arrays.asList(1), Arrays.asList(2, 3), Arrays.asList(4, 5, 6));
Iterator<List<Integer>> combinations = new Combinations<>(elements);
combinations.forEachRemaining(System.out::println);
origin: stackoverflow.com

 String s = "1 56 123 30 0";

Iterator<Double> it = new DoubleIterator(new ByteArrayInputStream(s.getBytes()));
while(it.hasNext()) {
  System.out.println(it.next());
}
it = new NoiseIterator(new DoubleIterator(new ByteArrayInputStream(s.getBytes())));
while(it.hasNext()) {
  System.out.println(it.next());
}
origin: stackoverflow.com

 List<String> strings = Arrays.asList( "1","2","3" ) ;

// Create our mapping Iterator
Iterator<Integer> iter = new Collector<>( strings, new Mapper<String,Integer>() {
  @Override
  public Integer apply( String v ) {
    return Integer.parseInt( v ) * 2 ;
  }
} ) ;

// Collect back from iterator into a List
List<Integer> numbers = new ArrayList<>() ;
while( iter.hasNext() ) {
  numbers.add( iter.next() ) ;
}
origin: stackoverflow.com

 Predicate<Object[]> predicate = new Predicate<>() {
          evaluate(Object[] obj) { 
             return (obj[2].equals("Closed")); 
          }
        };

Iterator<Object[]> filteredIterator = new FilterIterator<>(
              resultList.iterator, 
              predicate
            );
origin: stackoverflow.com

 Iterator sheetInterator = new Itertor();
Set<Object> set = new HashSet();
while(sheetInterator.hasNext()) { 
  Row myrow = (Row) obj.next();
  Iterator rowIterator = myrow.iterator();
  while(rowIterator.hasNext()) {
    Cell cell = (Cell) rowIterator.next();
    String value = cell.getValue();
    if(!set.add(value)){
      // value has not been added to the set -> it is at least 2nd occurrence of this value 
    }
  }
}
java.utilIterator<init>

Popular methods of Iterator

  • next
  • hasNext
    Returns true if there is at least one more element, false otherwise.
  • remove
  • forEachRemaining

Popular in Java

  • Reactive rest calls using spring rest template
  • getSupportFragmentManager (FragmentActivity)
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • BoxLayout (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now