Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sampleMultiple: possible incorrect javadoc comments #11

Open
php-coder opened this issue Nov 6, 2017 · 1 comment
Open

sampleMultiple: possible incorrect javadoc comments #11

php-coder opened this issue Nov 6, 2017 · 1 comment

Comments

@php-coder
Copy link

/**
* 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?
@ctapobep
Copy link
Member

ctapobep commented Nov 8, 2017

List sampleMultiple mentions that "elements don't repeat" but it returns a List that could have duplicates.

Are you saying that the result can have duplicates because the input may have duplicates? We can fix JavaDocs in that case to be clearer. The idea of the method is that it doesn't return same element twice (as opposed to sampling with replacement).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants