What is the difference between an Iterator and a Spliterator? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 163: What is the difference between an Iterator and a Spliterator?
Рекомендации по теме
Комментарии
Автор

So basically a visitor with a single visit method.

cverde
Автор

The funny thing is a iterator and splitIterator are so similar that you could make them the exact same thing.

The split function is simply just advancing the iterator index and giving a new instance that contains a copied range of data to the new instance.

While the tryAdvance method is simply a method that allows you to stop at any point during the iteration while the forEach method doesnt...
And the estimate size function is just a function that either returns -1 if it doesnt know or just returns the backing collections size...

All things the iterator could/should have too...

Speiger
join shbcf.ru