// addhead adds the item by searching from the the head.
addhead adds the item by searching from the the head.
// addhead adds the item by searching from the the head .
func (ttl *TTL) addhead(item *Item) {
	var last *Item
	for curr := ttl.head; curr != nil; curr = curr.next {
		if curr.timeoutAt.After(item.timeoutAt) {
			if last == nil {
				ttl.head = item
			} else {
				last.next = item
				if last.next != nil {
					last.next.prev = item
				}
				item.prev = last
				item.next = last.next
			}
			item.next = curr
			curr.prev = item
			return
		}
		last = curr
	}
	if last == nil {
		ttl.head = item
		ttl.tail = item
	} else {
		last.next = item
		item.prev = last
		if last == ttl.tail {
			ttl.tail = item
		}
	}
}
func ( ttl * TTL ) addhead ( item * Item ) { var last * Item for curr := ttl . head ; curr != nil ; curr = curr . next { if curr . timeoutAt . After ( item . timeoutAt ) { if last == nil { ttl . head = item } else { last . next = item if last . next != nil { last . next . prev = item } item . prev = last item . next = last . next } item . next = curr curr . prev = item return } last = curr } if last == nil { ttl . head = item ttl . tail = item } else { last . next = item item . prev = last if last == ttl . tail { ttl . tail = item } } }
addhead adds the item by searching from the the head.
addhead adds the item by searching from the the head .