Method delete
/* Delete one instance of item from the multiset, if there is one. */
public void delete(int item)
{
int k = search(item);
if ( k != currentSize )
if (freq[k] > 1)
freq[k]--;
else {
/* Last occurrence of item. */
currentSize--;
list[k] = list[currentSize];
freq[k] = freq[currentSize];
}
}
Previous slide
Next slide
Back to first slide
View graphic version