|
Boost : |
From: Ben Bear (benbearchen_at_[hidden])
Date: 2006-09-15 09:09:49
Hi, all!
I wrote a proposal for TR2 about add combination against
std::permutation. It's here:
http://www.bxmy.org/article/tr2/combi_tr2.txt
And the source code:
http://www.bxmy.org/article/tr2/combination.hpp
http://www.bxmy.org/article/tr2/test.cpp
I need HELP! Because my bad ability in English, can anybody edit
this report? And can anybody commit this proposal to WG21?
One year ago, I wrote a email to the libstdc++ group for the
combination, and they said that I should commit this to the Boost. I
wrote a email to this mailing list one month ago, but nobody replies me.
Maybe I should write the proposal for TR2. Now I wrote a draft.
Because the combination and the permutation are a pair in the
Mathematics. So it's needed to provide combination against the
std::permutation.
I have implemented the combination for several years. Now, I think my
implementation is very pithy and is parallel to the permutation's
implementation.
The difference between combination and permutation is that combination
needs initialization functions and the elements are divided into two
ranges, selected and unselected. The combination is several times
slow than the permutation.
Example:
// select two number from {0, 1, 2, 3, 4}
int a[5] = {0, 1, 2, 3, 4};
init_combination (a, a+2, a+5);
do
{
cout << a[0] << " " << a[1] << endl;
}
while (next_combination (a, a+2, a+5));
The result is:
0 1
0 2
0 3
0 4
1 2
1 3
1 4
2 3
2 4
3 4
Thanks.
Ben Bear in Guangzhou, China
2006/09/15
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk