code: public static int clear (int[] list, int value)
      {
          // nothing to clear from an empty list
          if (list == null) {
              return 0;
          }
  
          int llength = list.length; // no optimizing bastards
          for (int i = 0; i < llength; i++) {
              int val = list[i];
              if (val == value) {
                  list[i] = 0;
                  return val;
              }
          }
          return 0;
      }
docs: Clears out the first value that is equal to the supplied
  value. Passing a zero <code>value</code> to this function will
  cleverly tell you the index of the first empty element in the array
  which it will have kindly overwritten with zero just for good
  measure.
  
  @return the value that was removed or zero if it was not found.