Skip to content

sampleMultiple: possible incorrect javadoc comments #11

@php-coder

Description

@php-coder

/**
* Returns multiple random elements from the specified collection.
*
* @param toSampleFrom the population of the elements you'd like to get a random value from
* @return 0 or more elements of the specified collection, elements don't repeat
*/
public static <T> List<T> sampleMultiple(Collection<T> toSampleFrom) {
return sampleMultiple(integer(toSampleFrom.size()), toSampleFrom);
}
/**
* Returns multiple random elements from the specified collection.
*
* @param toSampleFrom the population of the elements you'd like to get a random value from
* @return a random element from the collection
*/
public static <T> Set<T> sampleMultiple(Set<T> toSampleFrom) {
return new HashSet<T>(sampleMultiple((Collection<T>) toSampleFrom));
}

I think that there 2 errors:

  • Set<T> sampleMultiple has an incorrect comment "@return a random element from the collection" because it doesn't return an element but a set of elements
  • List<T> sampleMultiple mentions that "elements don't repeat" but it returns a List that could have duplicates. Perhaps, this is addressed to Set<T> sampleMultiple?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions