java.lang.Object
org.bzdev.geom.SurfaceIteratorSplitter
Split a surface iterator into multiple surface iterators,
each covering a portion of a surface.
Some algorithms (e.g., the computation of moments, centers of
mass, volumes, etc.) perform essentially the same computation
on a surface's segments, and the results of those computations
can be summed. If each is summed on a different thread,
running time can be improved on a multiprocessor as long as
the processing time per segment is large compared to the time
used in managing multiple processes.
Segments are passed to subiterators when needed, so depending on usage, the number of segments each subiterator processes is not predictable. Similarly the segments each subiterator obtains is not predictable: there is no attempt to keep nearby segments together, for example.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetSurfaceIterator
(int index) Get the ith subiterator.void
Interrupt the thread generating surface iterator values.int
size()
Get the number of subiterators.
-
Constructor Details
-
SurfaceIteratorSplitter
Constructor. Generally, n should be no more than 1 less than the number of processors (this class creates one thread for internal use) if the computation is to be sped up.- Parameters:
n
- the number of subiterators to create.sit
- the original surface iterator.
-
-
Method Details
-
interrupt
public void interrupt()Interrupt the thread generating surface iterator values. -
size
public int size()Get the number of subiterators.- Returns:
- the number of subiterators
-
getSurfaceIterator
Get the ith subiterator.- Parameters:
index
- the index for the subiterator (an integer in the range [0, n) where n is the number of subiterators)- Returns:
- the ith subiterator
-