@Override
  public boolean remove(Object element) {
    if (hasLimitIterator) {
      return super.remove(element);
    } else {
      if (element == null) {
        if (numNulls > 0) {
          numNulls--;
          size--;
          assert size >= 0 : size;
          return true;
        } else {
          return false;
        }
      }
      int count = mapGet(element); // 0 if not
                                   // found
      if (count == 0) {
        return false;
      }
      if (count == 1) {
        mapRemove(element);
      } else {
        mapPut(element, --count);
      }
      size--;
      assert size >= 0 : size;
      return true;
    }
  }
Return an iterator over the elements in this collection. Duplicates will show up the number of
times it has occurrences.
geode-core/src/main/java/org/apache/geode/cache/query/internal/Bag.java