wenxiangtune / combinatoricslib

Automatically exported from code.google.com/p/combinatoricslib
0 stars 0 forks source link

Using an iterator rather than a vector? #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I would like the equivalent of the Python itertools.combinations(iterable, r)

See: http://docs.python.org/2/library/itertools.html#itertools.combinations

I wish to make a SimpleCombination of Integers over a range. As best as I can 
tell, all of your code requires generating a vector the size of the entire 
range which could be hundreds of thousands.

Thanks!

Original issue reported on code.google.com by PeterVermont on 19 Dec 2012 at 9:40

GoogleCodeExporter commented 8 years ago
On using the library I understand better why the code is structured as it is -- 
given that you are going to returning the vector objects in the combinations, 
there is little harm in having the user create them up front. I can also use 
the Range factory method.

I ended up really liking this way of doing things. By changing the items I sent 
in my original vector I got very useful control over exactly what was iterated 
which eliminated costly post hoc filtering.

It still might be useful to not require a vector in which case you would return 
a combination just made of indices into a specified range.

Original comment by PeterVermont on 20 Dec 2012 at 6:26

GoogleCodeExporter commented 8 years ago

Original comment by d.pau...@gmail.com on 31 Jan 2013 at 1:48