class AnalyzeUtils {

    static public List<Fragment> getSampleFragments(List<Fragment> fragments,
                                                    RequestContext context) {

        int listSize = fragments.size();
        int maxSize = context.getStatsMaxFragments();
        List<Fragment> samplingList = new ArrayList<Fragment>();
        BitSet bitSet;

        if (maxSize == 0) {
            return fragments;
        }

        LOG.debug("fragments list has " + listSize
                + " fragments, maxFragments = " + maxSize);

        bitSet = generateSamplingBitSet(listSize, maxSize);

        for (int i = 0; i < listSize; ++i) {
            if (bitSet.get(i)) {
                samplingList.add(fragments.get(i));
            }
        }

        return samplingList;
    }

}