You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2013/05/14 00:49:16 UTC

[jira] [Updated] (COLLECTIONS-448) Proposal for adding random pick methods to Bags

     [ https://issues.apache.org/jira/browse/COLLECTIONS-448?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Neidhart updated COLLECTIONS-448:
----------------------------------------

    Summary: Proposal for adding random pick methods to Bags  (was: Proposal for addinig random pick methods to Bags)
    
> Proposal for adding random pick methods to Bags
> -----------------------------------------------
>
>                 Key: COLLECTIONS-448
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-448
>             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.
> -----------------------------------------------------------------
> http://mail-archives.apache.org/mod_mbox/commons-dev/201303.mbox/%3CCAChO4O-YRE%3Db1%3D4hEK%2BuhvpV6-OD3F3apyRn3mwjvGzUEXe%2BaQ%40mail.gmail.com%3E
> 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: http://www.atlassian.com/software/jira