Othmen TILIOUINE created COLLECTIONS-448:
--------------------------------------------

             Summary: [PATCH] Proposal for addinig 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


Hello,

This is a patch to add row methods to Bag interfaces 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 not 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 add 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

Reply via email to