On 03/17/2013 03:02 AM, Ted Dunning wrote:
> I think that this implementation is a problem.
> 
> Bag implementations tend to fall into different categories, according to
> whether they provide unit (or log) time random access, random deletion and
> ordered traversal.  Most implementations don't provide unit time for all
> operations.
> 
> I think that your implementation assumes multiple operations have unit
> time.  Otherwise sampling all of the items will take quadratic time.
> 
> Also, your implementations alter the underlying collections.  That seems
> like a bad policy.
> 
> Sampling without replacement can be implemented as iteration over a
> permutation with unit amortized time.  A trivial implementation uses
> an auxiliary array.  It is also possible to do without the auxiliary.  You
> can get unit amortized time for linked list permutations as well, but it is
> difficult to do without the extra storage.
> 
> Finally, the names should not consist of combinations of "pick" and
> "remit".  The correct English terms are "sample" and "replacement".

additionally, I would prefer this feature to be a decorator rather than
altering the bag interface for it.

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to