// add will insert the fingerprint into the filter returning an error if the
// filter is full.
190000
func (c *CuckooFilter) add(i1, i2 uint, f []byte) error {
	// Try to insert into bucket[i1].
	b1 := c.buckets[i1%c.m]
	if idx, err := b1.getEmptyEntry(); err == nil {
		b1[idx] = f
		c.count++
		return nil
	}

	// Try to insert into bucket[i2].
	b2 := c.buckets[i2%c.m]
	if idx, err := b2.getEmptyEntry(); err == nil {
		b2[idx] = f
		c.count++
		return nil
	}

	// Must relocate existing items.
	i := i1
	for n := 0; n < maxNumKicks; n++ {
		bucketIdx := i % c.m
		entryIdx := rand.Intn(int(c.b))
		f, c.buckets[bucketIdx][entryIdx] = c.buckets[bucketIdx][entryIdx], f
		i = i ^ uint(binary.BigEndian.Uint32(c.computeHash(f)))
		b := c.buckets[i%c.m]
		if idx, err := b.getEmptyEntry(); err == nil {
			b[idx] = f
			c.count++
			return nil
		}
	}

	return errors.New("full")
}
16117
func (b *Bitmap) Add(a ...uint64) (changed bool, err error) {
	changed = false
	for _, v := range a {
		// Create an add operation.
		op := &op{typ: opTypeAdd, value: v}

		// Write operation to op log.
		if err := b.writeOp(op); err != nil {
			return false, err
		}

		// Apply to the in-memory bitmap.
		if b.DirectAdd(v) {
			changed = true
		}
	}

	return changed, nil
}
537693
func (i IntCounter) Add(key int) (changed bool) {
	value, exists := i[key]
	if !exists {
		changed = true
	}
	i[key] = value + 1
	return changed
}
245566
func (cf *Filter) Insert(data []byte) bool {
	i1, i2, fp := getIndicesAndFingerprint(data, uint(len(cf.buckets)))
	if cf.insert(fp, i1) || cf.insert(fp, i2) {
		return true
	}
	return cf.reinsert(fp, randi(i1, i2))
}
1141465
func (s *cacheShard) add(index uint64, obj interface{}) bool {
	s.Lock()
	defer s.Unlock()
	_, isOverwrite := s.items[index]
	if !isOverwrite && len(s.items) >= s.maxSize {
		var randomKey uint64
		for randomKey = range s.items {
			break
		}
		delete(s.items, randomKey)
	}
	s.items[index] = obj
	return isOverwrite
}
706243
func (c *Chain) Add(filter interface{}) {
	switch filter.(type) {
	case Filter:
		break
	case FilterFunc:
		break
	case func(*Update) bool:
		break
	default:
		panic("telebot: unsupported filter type")
	}

	c.Filters = append(c.Filters, filter)
}
1258373
func (c *IDTokenClaims) Add(key string, value interface{}) {
	if c.Extra == nil {
		c.Extra = make(map[string]interface{})
	}
	c.Extra[key] = value
}
1035247
func (s *simpleCache) Add(id uint64, b *Row) {
	s.cache[id] = b
}
604334
func (s *ProcessingStats) Add(counter *uint64, amount int) {
	atomic.AddUint64(counter, uint64(amount))
}
619178
func (c *Client) Add(key, val string, flags, exp uint32) (cas uint64, err error) {
	// Variants: Add [Q]
	return c.setGeneric(opAdd, key, val, 0, flags, exp)
}
1148771
func (err *MultiError) Add(errOrNil error) {
	if err != nil && errOrNil != nil {
		*err = append(*err, errOrNil)
	}
}
2031
func (m *Migrations) Add(id int, stmts ...string) {
	*m = append(*m, Migration{ID: id, Stmts: stmts})
}
1096605
func (t *Trace) Add(samples ...*ssf.SSFSample) {
	t.Samples = append(t.Samples, samples...)
}
544955
func (b *SampleFJSONBuilder) Add(info *SampleFPropertyInfo) *SampleFJSONBuilder {
	b._properties[info.fieldName] = info
	return b
}
1113371
func (c *DbClient) Add(path string, entry *decoder.FileDataEntry) {
	c.Lock()
	defer c.Unlock()

	if entry == nil {
		return
	}

	fileData, ok := c.db[path]
	if ok {
		value, ok := fileData[entry.Key]
		if ok {
			if !bytes.Equal(value.data, entry.Value) {
				rev := value.rev + 1
				fileData[entry.Key] = &dbEntry{entry.Value, rev}
			}
		} else {
			fileData[entry.Key] = &dbEntry{entry.Value, initialRev}
		}
	} else {
		fileData = map[string]*dbEntry{entry.Key: {entry.Value, initialRev}}
	}

	c.db[path] = fileData
}
182209
func (d *SilenceDetector) Add(samples []int32, sampleRate int, silenceMaxAudioLevel float64) (validSamples [][]int32) {
	// Append new samples
	*d.samples = append(*d.samples, samples...)

	// Get number of samples per audio level analysis
	var audioLevelAnalysisSamplesCount = int(math.Floor(float64(sampleRate) * d.c.StepDuration.Seconds()))

	// Get number of processed samples
	var processedSamplesCount = len(*d.audioLevels) * audioLevelAnalysisSamplesCount

	// Get number of processable samples
	var processableSamplesCount = len(*d.samples) - processedSamplesCount

	// Not enough processable samples
	if processableSamplesCount < audioLevelAnalysisSamplesCount {
		return
	}

	// Compute audio levels
	for i := 0; i < int(math.Floor(float64(processableSamplesCount)/float64(audioLevelAnalysisSamplesCount))); i++ {
		// Offsets
		start := processedSamplesCount + int(i*audioLevelAnalysisSamplesCount)
		end := start + audioLevelAnalysisSamplesCount

		// Append audio level
		*d.audioLevels = append(*d.audioLevels, AudioLevel((*d.samples)[start:end]))
	}

	// Count silences at the start
	var silencesCount int
	for _, l := range *d.audioLevels {
		if l < silenceMaxAudioLevel {
			silencesCount++
		} else {
			break
		}
	}

	// Keep 1 silence at the start
	if silencesCount > 1 {
		*d.audioLevels = (*d.audioLevels)[silencesCount-1:]
		*d.samples = (*d.samples)[(silencesCount-1)*audioLevelAnalysisSamplesCount:]
	}

	// Not enough audio levels to process silences in the middle
	if len(*d.audioLevels) <= 1 {
		return
	}

	// Process silences in the middle
	var i int
	silencesCount = 0
	for i = 1; i < len(*d.audioLevels); i++ {
		// Silence detected
		if (*d.audioLevels)[i] < silenceMaxAudioLevel {
			silencesCount++
			continue
		}

		// Process silences
		d.processSilencesInTheMiddle(audioLevelAnalysisSamplesCount, i, silencesCount, &validSamples)

		// Reset
		silencesCount = 0
	}

	// Process remaining silences
	d.processSilencesInTheMiddle(audioLevelAnalysisSamplesCount, i, silencesCount, &validSamples)
	return
}
1373562
func (self *StandardFilterer) AddFilter(filter Filter) {
	if !self.filters.SetContains(filter) {
		self.filters.SetAdd(filter)
	}
}