commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Othmen TILIOUINE (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (COLLECTIONS-448) [PATCH] Proposal for addinig random pick methods to Bags
Date Wed, 13 Mar 2013 07:42:12 GMT

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

Othmen TILIOUINE updated COLLECTIONS-448:
-----------------------------------------

    Description: 
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
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

  was:
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

    
> [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
>              Labels: patch
>         Attachments: pickFromABag.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 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

Mime
View raw message