public int addAndGetOccurence(Object element) {
    int occurrence;
    if (element == null) {
      numNulls++;
      occurrence = numNulls;
    } else {
      occurrence = mapGet(element); // 0 if not
                                    // found
      mapPut(element, ++occurrence);
    }
    size++;
    assert size >= 0 : size;
    return occurrence;
  }
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