Diff
checker
Texto
Texto
Imágenes
Documentos
Excel
Carpetas
Legal
Enterprise
Aplicación de escritorio
Precios
Iniciar sesión
Descargar Diffchecker Desktop
Comparar texto
Encuentra la diferencia entre dos archivos de texto
Herramientas
Historial
Editor live
Ocultar sin cambios
Sin ajuste de línea
Vista
Dividido
Unificado
Nivel de detalle
Inteligente
Palabra
Letra
Resaltado de sintaxis
Elegir sintaxis
Ignorar
Transformar texto
Ir al primer cambio
Editar entrada
Diffchecker Desktop
La forma más segura de usar Diffchecker. ¡Obtén la app de Diffchecker Desktop: tus diffs nunca salen de tu computadora!
Obtener Desktop
Defined Concurrency
Creado
hace 4 años
El diff nunca expira
Borrar
Exportar
Compartir
Explicar
4 eliminaciones
Líneas
Total
Eliminado
Caracteres
Total
Eliminado
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
24 líneas
Copiar todo
21 adiciones
Líneas
Total
Añadido
Caracteres
Total
Añadido
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
41 líneas
Copiar todo
Copiar
Copiado
Copiar
Copiado
import
"sync"
import
(
"runtime"
"sync"
)
var _concurrency = runtime.NumCPU()
func MaxConcurrency(concurrency int) {
_concurrency = concurrency
}
// Map manipulates a slice and transforms it to a slice of another type.
// Map manipulates a slice and transforms it to a slice of another type.
// `iteratee` is call in parallel. Result keep the same order.
// `iteratee` is call in parallel. Result keep the same order.
func Map[T any, R any](collection []T, iteratee func(T, int) R) []R {
func Map[T any, R any](collection []T, iteratee func(T, int) R) []R {
result := make([]R, len(collection))
result := make([]R, len(collection))
Copiar
Copiado
Copiar
Copiado
c := _concurrency
if c <= 0 {
c = len(collection)
}
routines := make(chan struct{}, c)
var wg sync.WaitGroup
var wg sync.WaitGroup
Copiar
Copiado
Copiar
Copiado
wg.Add(len(collection))
for i, item := range collection {
for i, item := range collection {
Copiar
Copiado
Copiar
Copiado
wg.Add(1)
go func(_item T, _i int) {
go func(_item T, _i int) {
Copiar
Copiado
Copiar
Copiado
defer wg.Done()
routines <- struct{}{}
res := iteratee(_item, _i)
res := iteratee(_item, _i)
Copiar
Copiado
Copiar
Copiado
<-routines
result[_i] = res
result[_i] = res
Copiar
Copiado
Copiar
Copiado
wg.Done()
}(item, i)
}(item, i)
}
}
wg.Wait()
wg.Wait()
return result
return result
}
}
Diferencias guardadas
Texto original
Abrir archivo
import "sync" // Map manipulates a slice and transforms it to a slice of another type. // `iteratee` is call in parallel. Result keep the same order. func Map[T any, R any](collection []T, iteratee func(T, int) R) []R { result := make([]R, len(collection)) var wg sync.WaitGroup wg.Add(len(collection)) for i, item := range collection { go func(_item T, _i int) { res := iteratee(_item, _i) result[_i] = res wg.Done() }(item, i) } wg.Wait() return result }
Texto modificado
Abrir archivo
import ( "runtime" "sync" ) var _concurrency = runtime.NumCPU() func MaxConcurrency(concurrency int) { _concurrency = concurrency } // Map manipulates a slice and transforms it to a slice of another type. // `iteratee` is call in parallel. Result keep the same order. func Map[T any, R any](collection []T, iteratee func(T, int) R) []R { result := make([]R, len(collection)) c := _concurrency if c <= 0 { c = len(collection) } routines := make(chan struct{}, c) var wg sync.WaitGroup for i, item := range collection { wg.Add(1) go func(_item T, _i int) { defer wg.Done() routines <- struct{}{} res := iteratee(_item, _i) <-routines result[_i] = res }(item, i) } wg.Wait() return result }
Encontrar la diferencia