Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
Defined Concurrency
作成日
4 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
4 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
24 行
すべてコピー
21 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
41 行
すべてコピー
コピー
コピー済み
コピー
コピー済み
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))
コピー
コピー済み
コピー
コピー済み
c := _concurrency
if c <= 0 {
c = len(collection)
}
routines := make(chan struct{}, c)
var wg sync.WaitGroup
var wg sync.WaitGroup
コピー
コピー済み
コピー
コピー済み
wg.Add(len(collection))
for i, item := range collection {
for i, item := range collection {
コピー
コピー済み
コピー
コピー済み
wg.Add(1)
go func(_item T, _i int) {
go func(_item T, _i int) {
コピー
コピー済み
コピー
コピー済み
defer wg.Done()
routines <- struct{}{}
res := iteratee(_item, _i)
res := iteratee(_item, _i)
コピー
コピー済み
コピー
コピー済み
<-routines
result[_i] = res
result[_i] = res
コピー
コピー済み
コピー
コピー済み
wg.Done()
}(item, i)
}(item, i)
}
}
wg.Wait()
wg.Wait()
return result
return result
}
}
保存された差分
原文
ファイルを開く
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 }
変更されたテキスト
ファイルを開く
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 }
違いを見つける