commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <>
Subject [jira] [Commented] (COLLECTIONS-448) [PATCH] Proposal for addinig random pick methods to Bags
Date Wed, 08 May 2013 11:15:16 GMT


Thomas Neidhart commented on COLLECTIONS-448:

Link to the discussion on the mailinglist
> [PATCH] Proposal for addinig random pick methods to Bags
> --------------------------------------------------------
>                 Key: COLLECTIONS-448
>                 URL:
>             Project: Commons Collections
>          Issue Type: Wish
>          Components: Bag
>    Affects Versions: 4.0
>            Reporter: Othmen Tiliouine
>            Priority: Minor
>              Labels: patch
>             Fix For: 4.x
>         Attachments: pickFromABag2.patch
>   Original Estimate: 4h
>  Remaining Estimate: 4h
> Hello,
> This is a patch to add two methods to Bag interface and classes
>     public E pick();
>     public E pickAndRemit();
> as discussed in this mail.
> -----------------------------------------------------------------
> I just saw the Bag interface and its implementations, I'm surprised that Bag <T>
(and none of these implementations) expose the method
> public T pick() and public T pickAndRemit() (pick a random element)
> The Bag object we see in nature, it is mainly used to this, that's why it is widely used
in the probability that when I met 2 white balls and one black, when I draw a ball randomly
I have 2 times more likely to have a white ball
> I think that if this caracteristic exists it would be very valuable.
> ----------------------------------------------------------------------
> these methods pick a random element from the bag, The probability of picking a copy of
a given element is proportional to the number of copies of this element in the bag.
> the diference between pick() and pickAndRemit() is that with pick() the picked element
is removed from the bag. 
> this is my first contribution on open source project 
> if you accept to add this feature to bags and validate my patch i will propose one other
patch to add this methods
> public Iterator<E> pick(int n); //pick random n element (with remove)
> public Iterator<E> pickAndRemit(int n) ; //pick random n element (without remove)
> -Question : should i regenerate the serialVersionUID of classes that i have changed ?
> Othmen Tiliouine

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message