Thread: what is a Spliterator.

Forum : Collections   8 Aug, 2017 22:40
User Image
Samanta1

Newbie

Joined: 27 Jun, 2017

Points: 130

Threads: 8

Posts: 16

Answer Icon what is a Spliterator.

| Quote Date : 8 Aug, 2017    Views:5712    

what is a Spliterator.

tags: collections

Comments

User Image
sahwan

Newbie

Joined : 10 May, 2017

Points : 105

Threads: 7

Posts: 11

Answer IconRe: what is a Spliterator.

Reply Date : 8 Aug, 2017

A new interface added to java.util is the Spilterators, which as the name implies, is a new special kind of Iterator that can traverse a Collection.For Java 8, the Collection interface has been updated to include a new spliterator() method, that when called returns a Spliterator. This is not the case for the separate Map interface, although it is considered part of the Collections Framework.

The Spliterator can ?split? the Collection, partitioning off some of its elements as another Spliterator. This does allow parallel processing of different parts of a Collection but note that the Spliterator itself does not provide the parallel processing behavior. Instead, the Spliterator is there to support parallel traversal of the suitably partitioned parts of a Collection. This solves the problem of dividing the data, as held in a Collection such as an ArrayList, into suitably sized sub-units that can be processed in parallel.
The fork/join framework, which is found in Java 7 libraries, can be used with the Spliterator and is designed for parallelizable work that can be broken into smaller pieces recursively to be processed independently, and then aggregating the results of the sub-units to produce a final result.

User Image
deep24

Newbie

Joined : 3 Jul, 2017

Points : 100

Threads: 0

Posts: 2

Re: what is a Spliterator.

Reply Date : 8 Aug, 2017

This is special iterator which can be able to traverse a Collection ?and allow to parallel processing  to part of collection. 


Load More

No More Comments