mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 01:52:32 +02:00
5fdac82dd6
* (Add) Settings & Issues: Enable or disable Empty Layers * (Add) PrusaSlicer Printer: Nova Bene4 Mono * (Add) CWS: Support the GRAY2RGB and RBG2GRAY encoding for Bene Mono * (Add) Layer issue Z map paired with layer navigation tracker bar * (Change) Shortcuts: + and - to go up and down on layers were change to W and S keys. Reason: + and - are bound to zoom and can lead to problems * (Upgrade) OpenCV from 4.2 to 4.3 * (Fix) CWS: Add missing Platform X,Y,Z size when converting from SL1 * (Fix) CWS: Invert XY resolution when converting from SL1
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace UVtools.Core.Extensions
|
|
{
|
|
public static class ParallelExtensions
|
|
{
|
|
public static void ForAllInApproximateOrder<TSource>(this ParallelQuery<TSource> source, Action<TSource> action)
|
|
{
|
|
Partitioner.Create(source)
|
|
.AsParallel()
|
|
.AsOrdered()
|
|
.ForAll(action);
|
|
}
|
|
|
|
public static void ForEachInApproximateOrder<TSource>(this ParallelQuery<TSource> source, Action<TSource> action)
|
|
{
|
|
|
|
source = Partitioner.Create(source)
|
|
.AsParallel()
|
|
.AsOrdered();
|
|
|
|
Parallel.ForEach(source, action);
|
|
|
|
}
|
|
|
|
public static IEnumerable<T1> OrderedParallel<T, T1>(this IEnumerable<T> list, Func<T, T1> action)
|
|
{
|
|
var unorderedResult = new ConcurrentBag<(long, T1)>();
|
|
Parallel.ForEach(list, (o, state, i) =>
|
|
{
|
|
unorderedResult.Add((i, action.Invoke(o)));
|
|
});
|
|
var ordered = unorderedResult.OrderBy(o => o.Item1);
|
|
return ordered.Select(o => o.Item2);
|
|
}
|
|
}
|
|
}
|