Diff
checker
Texto
Texto
Imagens
Documentos
Excel
Pastas
Legal
Enterprise
Aplicativo para desktop
Preços
Fazer login
Baixar o Diffchecker Desktop
Comparar texto
Encontre a diferença entre dois arquivos de texto
Ferramentas
Histórico
Editor live
Recolher inalteradas
Sem quebra de linha
Layout
Dividido
Unificado
Nível de detalhe
Inteligente
Palavra
Caractere
Realce de sintaxe
Escolher sintaxe
Ignorar
Transformar texto
Ir à primeira mudança
Editar entrada
Diffchecker Desktop
A maneira mais segura de usar o Diffchecker. Obtenha o aplicativo Diffchecker Desktop: seus diffs nunca saem do seu computador!
Obter Desktop
Defined Concurrency
Criado
há 4 anos
O diff nunca expira
Limpar
Exportar
Compartilhar
Explicar
4 remoções
Linhas
Total
Removido
Caracteres
Total
Removido
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
24 linhas
Copiar tudo
21 adições
Linhas
Total
Adicionado
Caracteres
Total
Adicionado
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
41 linhas
Copiar tudo
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
}
}
Diferenças salvas
Texto original
Abrir arquivo
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 alterado
Abrir arquivo
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 Diferença