Though it isn't the focus of your question there is a much faster way to generate your example data:
Join[RandomReal[1, {n, 4}], Transpose[RandomInteger[#, n] & /@ {{-1, 2}, 15000}], 2]
For the problem itself I also chose Pick
but I used Transpose
and Positive
instead:
{Min@#, Max@#} & @ Pick[#6, Positive @ #5] & @@ (data\[Transpose])
This proves to be about twice as fast as sebhofer's code:
n = 1*^6;
data = Join[RandomReal[1, {n, 4}], Transpose[RandomInteger[#, n] & /@ {{-1, 2}, 15000}], 2]
{Min@#, Max@#} & @ Pick[#6, Positive @ #5] & @@ (data\[Transpose]) // Timing // First
Through[{Max, Min}@Pick[data[[;; , 6]], HeavisideTheta@data[[;; , 5]], 1]] // Timing // First
0.162241
0.343202
(Timings performed in version 10.0.)