groovyx.gpars.extra166y
Class PAS.FJOSorter

java.lang.Object
  extended by jsr166y.ForkJoinTask<java.lang.Void>
      extended by jsr166y.RecursiveAction
          extended by groovyx.gpars.extra166y.PAS.FJOSorter
All Implemented Interfaces:
java.io.Serializable, java.util.concurrent.Future<java.lang.Void>
Enclosing class:
PAS

static final class PAS.FJOSorter
extends jsr166y.RecursiveAction

Sorter classes based mainly on CilkSort Cilk: Basic algorithm: if array size is small, just use a sequential quicksort Otherwise: 1. Break array in half. 2. For each half, a. break the half in half (i.e., quarters), b. sort the quarters c. merge them together 3. merge together the two halves. One reason for splitting in quarters is that this guarantees that the final sort is in the main array, not the workspace array. (workspace and main swap roles on each subsort step.) Leaf-level sorts use a Sequential quicksort, that in turn uses insertion sort if under threshold. Otherwise it uses median of three to pick pivot, and loops rather than recurses along left path. It is sad but true that sort and merge performance are sensitive enough to inner comparison overhead to warrant creating 6 versions (not just 3) -- one each for natural comparisons vs supplied comparators.


Field Summary
(package private)  java.lang.Object[] a
           
(package private)  java.util.Comparator cmp
           
(package private)  int gran
           
(package private)  int n
           
(package private)  int origin
           
(package private)  java.lang.Object[] w
           
 
Constructor Summary
PAS.FJOSorter(java.util.Comparator cmp, java.lang.Object[] a, java.lang.Object[] w, int origin, int n, int gran)
           
 
Method Summary
 void compute()
           
 
Methods inherited from class jsr166y.RecursiveAction
exec, getRawResult, setRawResult
 
Methods inherited from class jsr166y.ForkJoinTask
adapt, adapt, adapt, cancel, complete, completeExceptionally, fork, get, get, getException, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollTask, quietlyInvoke, quietlyJoin, reinitialize, tryUnfork
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cmp

final java.util.Comparator cmp

a

final java.lang.Object[] a

w

final java.lang.Object[] w

origin

final int origin

n

final int n

gran

final int gran
Constructor Detail

PAS.FJOSorter

PAS.FJOSorter(java.util.Comparator cmp,
              java.lang.Object[] a,
              java.lang.Object[] w,
              int origin,
              int n,
              int gran)
Method Detail

compute

public void compute()
Specified by:
compute in class jsr166y.RecursiveAction

Copyright © 2008–2012 Václav Pech. All Rights Reserved.