All pastes #2054388 Raw Edit

Unnamed

public c v1 · immutable
#2054388 ·published 2011-05-05 23:03 UTC
rendered paste body
        case REMOVEALL: /* removes ALL occurrences of <num> in the list, return number of elements removed */                for (i = 0; i < stack.size; i++)                {                        int j;                        if (stack.data[i] == arg)       /* found occurrence of <num> */                        {                                n++;    /* increment number of <num>'s found */                                for (j = i; j+1 < stack.size; j++)      /* shift the array over */                                        stack.data[j] = stack.data[j+1];                                stack.size--;                                i--;    /* this makes the loop check the SAME slot again, because the one replaced it with could possibly be <num> */                        }                }