// Remove a timeout object from the queue according to the key
Remove a timeout object from the queue according to the key
// Remove a timeout object from the queue according to the key
func (q *TimeoutQueue) Remove(key interface{}) (interface{}, bool) {
	q.mu.Lock()
	defer q.mu.Unlock()
	if i, ok := q.index[key]; ok {
		toRemove := q.data[i].Data
		delete(q.index, key)
		q.data = append(q.data[:i], q.data[i+1:]...)
		for i, d := range q.data {
			q.index[d.Key] = i
		}
		return toRemove, true
	}
	return nil, false
}
func ( q * TimeoutQueue ) Remove ( key interface { } ) ( interface { } , bool ) { q . mu . Lock ( ) defer q . mu . Unlock ( ) if i , ok := q . index [ key ] ; ok { toRemove := q . data [ i ] . Data delete ( q . index , key ) q . data = append ( q . data [ : i ] , q . data [ i + 1 : ] ... ) for i , d := range q . data { q . index [ d . Key ] = i } return toRemove , true } return nil , false }
Remove a timeout object from the queue according to the key
Remove a timeout object from the queue according to the key
// rebuild index