// DeleteWithHint deletes a value for a key.
// The hash/seed params must be previous generated from the Hash function
// sharing the same key. Doing otherwise will risk corruption to map.
// Returns the deleted value, or false when no value was assigned.
DeleteWithHint deletes a value for a key.
The hash/seed params must be previous generated from the Hash function
sharing the same key. Doing otherwise will risk corruption to map.
Returns the deleted value, or false when no value was assigned.
// DeleteWithHint deletes a value for a key . // The hash / seed params must be previous generated from the Hash function // sharing the same key . Doing otherwise will risk corruption to map . // Returns the deleted value or false when no value was assigned .
func (m *Map) DeleteWithHint(key string, hash, seed uint32) (interface{}, bool) {
	if len(m.entries) == 0 {
		return nil, false
	}
	if atomic.LoadUint32(&m.seed) != seed {
		return m.Delete(key)
	}
	pos := int(hash)
	i := pos & m.mask
	oi := i
	for {
		if m.entries[i].dist == 0 {
			return nil, false
		}
		if m.entries[i].hash == hash && m.entries[i].key == key {
			old := m.entries[i].value
			m.entries[i].dist = 0
			for {
				pi := i
				i = (i + 1) & m.mask
				if m.entries[i].dist <= 1 {
					m.entries[pi] = entry{}
					break
				}
				m.entries[pi] = m.entries[i]
				m.entries[pi].dist--
			}
			m.len--
			if m.shrinkable && len(m.entries) > m.init &&
				m.len < len(m.entries)/8 {
				m.shrink()
			}
			return old, true
		}
		i = (i + 1) & m.mask
		if i == oi {
			return nil, false
		}
	}
}
func ( m * Map ) DeleteWithHint ( key string , hash , seed uint32 ) ( interface { } , bool ) { if len ( m . entries ) == 0 { return nil , false } if atomic . LoadUint32 ( & m . seed ) != seed { return m . Delete ( key ) } pos := int ( hash ) i := pos & m . mask oi := i for { if m . entries [ i ] . dist == 0 { return nil , false } if m . entries [ i ] . hash == hash && m . entries [ i ] . key == key { old := m . entries [ i ] . value m . entries [ i ] . dist = 0 for { pi := i i = ( i + 1 ) & m . mask if m . entries [ i ] . dist <= 1 { m . entries [ pi ] = entry { } break } m . entries [ pi ] = m . entries [ i ] m . entries [ pi ] . dist -- } m . len -- if m . shrinkable && len ( m . entries ) > m . init && m . len < len ( m . entries ) / 8 { m . shrink ( ) } return old , true } i = ( i + 1 ) & m . mask if i == oi { return nil , false } } }
DeleteWithHint deletes a value for a key.
DeleteWithHint deletes a value for a key .