Caller can specify source counts and quantities
This commit is contained in:
parent
39d849b955
commit
c41e28fdd5
21
main.go
21
main.go
@ -4,12 +4,31 @@ import (
|
||||
"container/heap"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const usage = "smerge [count, count, ... count]"
|
||||
|
||||
func main() {
|
||||
for i := range merge(source(500), source(100), source(200)) {
|
||||
args := os.Args[1:]
|
||||
if len(args) < 1 {
|
||||
fmt.Fprintf(os.Stderr, "usage: %v\n", usage)
|
||||
os.Exit(1)
|
||||
}
|
||||
srcs := []<-chan int{}
|
||||
for _, arg := range args {
|
||||
i, err := strconv.Atoi(arg)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
srcs = append(srcs, source(i))
|
||||
}
|
||||
for i := range merge(srcs...) {
|
||||
fmt.Printf("%20d\n", i)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user