// NewWriterPool creates new WriterPool that reuses writers which size is in
// logarithmic range [min, max].
969560
func NewWriterPool(min, max int) *WriterPool {
	return &WriterPool{pool.New(min, max)}
}
755529
func NewMaxWidthWriter(w io.Writer, maxWidth uint) io.Writer {
	return &maxWidthWriter{
		maxWidth: maxWidth,
		writer:   w,
	}
}
911207
func NewWriter(w io.Writer) *BitWriter {
	b := new(BitWriter)
	b.w = w
	b.count = 8
	return b
}
558539
func NewWriter(simple bool, buf ...byte) (w *Writer) {
	w = new(Writer)
	w.buf = buf
	w.Simple = simple
	return
}
698462
func NewPool(opts Options) Pool {
	p := &poolOfContexts{
		ctxPool: pool.NewObjectPool(opts.ContextPoolOptions()),
		finalizersPool: newFinalizeablesArrayPool(finalizeablesArrayPoolOpts{
			Capacity:    opts.InitPooledFinalizerCapacity(),
			MaxCapacity: opts.MaxPooledFinalizerCapacity(),
			Options:     opts.FinalizerPoolOptions(),
		}),
	}

	p.finalizersPool.Init()
	p.ctxPool.Init(func() interface{} {
		return newPooledContext(p)
	})

	return p
}
653699
func NewBufferedWriter(size int) WriterMiddleware {
    return func(writeCloser io.WriteCloser) io.WriteCloser {
        return &bufferedWriter{bufio.NewWriterSize(writeCloser, size), writeCloser}
    }
}
278231
func NewPool(opts ...Option) *Pool {
	pool := &Pool{}
	for _, opt := range opts {
		opt(pool)
	}
	return pool
}
995491
func NewPool(ctx context.Context, dialOptions ...grpc.DialOption) *Pool {
	return &Pool{
		bgCtx:       ctx,
		dialOptions: dialOptions,
		conns:       make(map[string]*conn),
	}
}
154089
func NewObjectPool(ctx context.Context, factory PooledObjectFactory, config *ObjectPoolConfig) *ObjectPool {
	return NewObjectPoolWithAbandonedConfig(ctx, factory, config, nil)
}
21272
func NewWriter(w io.Writer) *Writer {
	if wr, ok := w.(*Writer); ok {
		return wr
	}
	return &Writer{
		w:   w,
		buf: make([]byte, 0, DefaultWriterSize),
	}
}
875520
func NewWriter(writer io.Writer, header *FileHeader) (*Writer, error) {
	w := &Writer{
		writer: writer,
		buf:    make([]byte, 24),
	}
	binary.LittleEndian.PutUint32(w.buf, header.MagicNumber)
	binary.LittleEndian.PutUint16(w.buf[4:], header.VersionMajor)
	binary.LittleEndian.PutUint16(w.buf[6:], header.VersionMinor)
	binary.LittleEndian.PutUint32(w.buf[8:], uint32(header.TimeZone))
	binary.LittleEndian.PutUint32(w.buf[12:], header.SigFigs)
	binary.LittleEndian.PutUint32(w.buf[16:], header.SnapLen)
	binary.LittleEndian.PutUint32(w.buf[20:], header.Network)
	if _, err := writer.Write(w.buf); err != nil {
		return nil, err
	}
	return w, nil
}
525614
func NewWriter(wr io.Writer) *Writer {
	mw := new(Writer)
	mw.Reset(wr)
	return mw
}
39705
func NewWriter(addr string) (*Writer, error) {
	var err error
	w := new(Writer)
	w.CompressionLevel = flate.BestSpeed

	if w.conn, err = net.Dial("udp", addr); err != nil {
		return nil, err
	}
	if w.hostname, err = os.Hostname(); err != nil {
		return nil, err
	}

	w.Facility = path.Base(os.Args[0])

	return w, nil
}
895941
func NewPool(seed int64, size uint64) *Pool {
	groupsize := nextNearestPow2uint64(size)
	pool := &Pool{
		size:    groupsize,
		sources: make([]NumberGenerator, groupsize),
	}
	// seed the pool
	pool.seed(seed)
	return pool
}
847091
func NewMemPool(N int64) Pool {
	return &memPool{
		N: N,
		Pool: NewPool(func() Buffer {
			return New(N)
		}),
	}
}
1240593
func NewWriter(w io.Writer) *Writer {
	return &Writer{
		raw:  w,
		zlib: zlib.NewWriter(w),
	}
}
1320813
func NewOrEmptyPool(network, addr string, size int) *Pool {
	pool, err := NewPool(network, addr, size)
	if err != nil {
		pool = &Pool{
			network: network,
			addr:    addr,
			pool:    make(chan *redis.Client, size),
			df:      redis.Dial,
		}
	}
	return pool
}