Since items are only removed on retrieval, calling the len method on the dictionary will return all the items in the dictionary--including the expired items.
Length should iterate through the internal list and find what items are expired and remove them appropriately. Since it's internally implemented using an OrderedDict, we can perform a binary search to find what items in the dictionary have expired in Log(n) time
Since items are only removed on retrieval, calling the
lenmethod on the dictionary will return all the items in the dictionary--including the expired items.Length should iterate through the internal list and find what items are expired and remove them appropriately. Since it's internally implemented using an
OrderedDict, we can perform a binary search to find what items in the dictionary have expired in Log(n) time