// add adds a k -> v mapping to the cache.
553965
func (c *linkAddrCache) add(k tcpip.FullAddress, v tcpip.LinkAddress) {
	c.mu.Lock()
	defer c.mu.Unlock()

	entry, ok := c.cache[k]
	if ok {
		s := entry.state()
		if s != expired && entry.linkAddr == v {
			// Disregard repeated calls.
			return
		}
		// Check if entry is waiting for address resolution.
		if s == incomplete {
			entry.linkAddr = v
		} else {
			// Otherwise create a new entry to replace it.
			entry = c.makeAndAddEntry(k, v)
		}
	} else {
		entry = c.makeAndAddEntry(k, v)
	}

	entry.changeState(ready)
}
97405
func (c *ReasonCache) add(uid types.UID, name string, reason error, message string) {
	c.lock.Lock()
	defer c.lock.Unlock()
	c.cache.Add(c.composeKey(uid, name), reasonItem{reason, message})
}
1148761
func (u *URLQueryParameters) Add(Key string, value string) {
	u.params = append(u.params, URLQueryParameter{Key: Key, Value: value})
}
376493
func (v1 Vec4) Add(v2 Vec4) Vec4 {
	return Vec4{v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2], v1[3] + v2[3]}
}
556060
func (c *ExpirationCache) Add(obj interface{}) error {
	key, err := c.keyFunc(obj)
	if err != nil {
		return KeyError{obj, err}
	}
	c.cacheStorage.Add(key, &timestampedEntry{obj, c.clock.Now()})
	return nil
}
430222
func (c *Cache) Add(key string, value interface{}) {
	if !c.nolock {
		c.mu.Lock()
		defer c.mu.Unlock()
	}

	// Already in cache?
	if ee, ok := c.cache[key]; ok {
		c.ll.MoveToFront(ee)
		ee.Value.(*entry).value = value
		return
	}

	// Add to cache if not present
	ele := c.ll.PushFront(&entry{key, value})
	c.cache[key] = ele

	if c.maxEntries > 0 && c.ll.Len() > c.maxEntries {
		c.removeOldest()
	}
}
1159622
func (c *keyValueChanger) Add(k string, v interface{}) error {
	if c.err != nil {
		return c.err
	}
	_, err := c.node.addChild(keyValue{k, v})
	return err
}
1117287
func (c CPUMap) Add(q CPUMap) {
	for label, value := range q {
		if _, ok := c[label]; !ok {
			c[label] = value
		} else {
			c[label] += value
		}
	}
}
343464
func (d *Dictionary) Add(key, value interface{}) {
	d.keys = append(d.keys, key)
	d.values = append(d.values, value)
}
760360
func (p parameters) add(key, value string) {
	url.Values(p).Add(key, value)
}
1258373
func (c *IDTokenClaims) Add(key string, value interface{}) {
	if c.Extra == nil {
		c.Extra = make(map[string]interface{})
	}
	c.Extra[key] = value
}
511356
func (decaying *Decaying) Add(d float64) {
	prevVal := decaying.Value()
	decaying.Lock()
	decaying.p = prevVal + d
	decaying.Unlock()
}
334714
func (r *cacheRegistry) Add(c *Cache) {
	r.Lock()
	defer r.Unlock()

	r.items[c.name] = c
}
1277780
func (g *Mutable) Add(v, w int) {
	g.AddCost(v, w, 0)
}
441735
func (mc *sqlMsgsCache) add(msg *pb.MsgProto, data []byte) {
	cachedMsg := mc.free
	if cachedMsg != nil {
		mc.free = cachedMsg.next
		cachedMsg.next = nil
		// Remove old message from the map
		delete(mc.msgs, cachedMsg.msg.Sequence)
	} else {
		cachedMsg = &sqlCachedMsg{}
	}
	cachedMsg.msg = msg
	cachedMsg.data = data
	mc.msgs[msg.Sequence] = cachedMsg
	if mc.head == nil {
		mc.head = cachedMsg
	} else {
		mc.tail.next = cachedMsg
	}
	mc.tail = cachedMsg
}
472234
func (t *KVMsTable) add(c context.Context) error {
	// Avoid using the database connection to prepare unnecessary statements.
	if len(t.additions) == 0 {
		return nil
	}

	tx, err := database.Begin(c)
	if err != nil {
		return errors.Annotate(err, "failed to begin transaction").Err()
	}
	defer tx.MaybeRollback(c)
	stmt, err := tx.PrepareContext(c, `
		INSERT INTO kvms (hostname_id, description, mac_address, state, platform_id, rack_id)
		VALUES (?, ?, ?, ?, ?, ?)
	`)
	if err != nil {
		return errors.Annotate(err, "failed to prepare statement").Err()
	}
	defer stmt.Close()

	// Add each KVM to the database, and update the slice of KVMs with each addition.
	for len(t.additions) > 0 {
		kvm := t.additions[0]
		hostnameId, err := AssignHostnameAndIP(c, tx, kvm.Name, kvm.IPv4)
		if err != nil {
			return errors.Annotate(err, "failed to add KVM %q", kvm.Name).Err()
		}
		result, err := stmt.ExecContext(c, hostnameId, kvm.Description, kvm.MacAddress, kvm.State, kvm.PlatformId, kvm.RackId)
		if err != nil {
			return errors.Annotate(err, "failed to add KVM %q", kvm.Name).Err()
		}
		t.current = append(t.current, kvm)
		t.additions = t.additions[1:]
		logging.Infof(c, "Added KVM %q", kvm.Name)
		kvm.Id, err = result.LastInsertId()
		if err != nil {
			return errors.Annotate(err, "failed to get KVM ID %q", kvm.Name).Err()
		}
	}

	if err := tx.Commit(); err != nil {
		return errors.Annotate(err, "failed to commit transaction").Err()
	}
	return nil
}
384529
func (c *UIDCache) Add(uid types.UID) {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	c.cache.Add(uid, nil)
}