// Cap returns capacity of the buffer.
// Cap returns 0 if it is a dummy write response for WriteCommand.
421299
func (r *responseWriter) Cap() int {
	if r.buf == nil {
		return 0
	}
	return r.buf.Cap()
}
544749
func (b *Buffer) Write(buf []byte) (int, error) {
	// Account for total bytes written
	n := len(buf)
	b.written += int64(n)

	// If the buffer is larger than ours, then we only care
	// about the last size bytes anyways
	if int64(n) > b.size {
		buf = buf[int64(n)-b.size:]
	}

	// Copy in place
	remain := b.size - b.writeCursor
	copy(b.data[b.writeCursor:], buf)
	if int64(len(buf)) > remain {
		copy(b.data, buf[remain:])
	}

	// Update location of the cursor
	b.writeCursor = ((b.writeCursor + int64(len(buf))) % b.size)
	return n, nil
}
1103004
func (c *Random) Cap() int {
	c.mu.RLock()
	defer c.mu.RUnlock()

	return c.cap
}
395714
func (s *RootStorage) SetCapacity(v string) *RootStorage {
	s.Capacity = &v
	return s
}
1310134
func (b *Buffer) Flush() (size int, err error) {
	for _, buf := range b.buffer {
		if size, err = b.write(buf); err != nil {
			return
		}
	}

	b.buffer = b.buffer[:0]
	return
}
955431
func Capacity(n uint) ClientParam {
	return func(cl *Client) error {
		cl.cap = n
		return nil
	}
}
835874
func (p *peerConnection) HeaderCapacity(targetRTT time.Duration) int {
	p.lock.RLock()
	defer p.lock.RUnlock()

	return int(math.Min(1+math.Max(1, p.headerThroughput*float64(targetRTT)/float64(time.Second)), float64(MaxHeaderFetch)))
}
689613
func (o *Osc) Fill(buf *audio.FloatBuffer) error {
	if o == nil {
		return nil
	}
	numChans := 1
	if f := buf.Format; f != nil {
		numChans = f.NumChannels
	}
	fameCount := buf.NumFrames()
	var sample float64
	for i := 0; i < fameCount; i++ {
		sample = o.Sample()
		for j := 0; j < numChans; j++ {
			buf.Data[i+j] = sample
		}
	}
	return nil
}
984337
func (b *Buffer) Pop(n int) {
	b.data = b.data[n:]
}
338671
func (b *Buffer) Write(p []byte) (n int, err error) {
	m := b.grow(len(p))
	return copy(b.buf[m:], p), nil
}
447288
func (t *Tx) Capacity(recordSize uint64) uint64 {
	available := uint64(len(t.p.buffer)) - sizeOfSlotHeader
	entryLen := payloadToSlotSize(recordSize)
	return available / entryLen
}
1279740
func (b *builderBuffer) growCapacity(n uint) {
	_b := *b
	curLen := uint(len(_b))
	curCap := uint(cap(_b))
	newCap := curLen + n
	if newCap <= curCap {
		// No need to do anything
		return
	}
	// Increase the capacity
	extra := newCap // Grow a bit more to avoid copying all the time
	if extra < minGrowDelta {
		extra = minGrowDelta
	} else if extra > maxGrowDelta {
		extra = maxGrowDelta
	}
	newBuffer := make(builderBuffer, curLen, newCap+extra)
	copy(newBuffer, _b)
	*b = newBuffer
}
679949
func ensureCap(s []byte, n int) []byte {
	if n <= cap(s) {
		return s
	}
	// logic adapted from appendslice1 in runtime
	m := cap(s)
	if m == 0 {
		m = n
	} else {
		for {
			if m < 1024 {
				m += m
			} else {
				m += m / 4
			}
			if m >= n {
				break
			}
		}
	}
	t := make([]byte, len(s), m)
	copy(t, s)
	return t
}
1289278
func (buf *Buffer) Write(p []byte) (int, error) {
	r := len(buf.buf) + len(p)
	if cap(buf.buf) < r {
		l := r
		for {
			if l > r {
				break
			}
			l *= 2
		}
		buf.grow(l - cap(buf.buf))
	}
	buf.buf = append(buf.buf, p...)
	return len(p), nil
}
1248777
func (cr *Context) GetLineCap() LineCap {
	ret := LineCap(C.cairo_get_line_cap(cr.Ptr))
	if err := cr.status(); err != nil {
		panic(err)
	}
	return ret
}
1052173
func Capacity(capacity int) ListOption {
	return listOptionFunc(func(options *listOptions) {
		options.capacity = capacity
	})
}
618388
func (lru *LRUCache) Capacity() int64 {
	lru.mu.Lock()
	defer lru.mu.Unlock()
	return lru.capacity
}