开发者

How to permute a list of objects in C#?

开发者 https://www.devze.com 2023-01-05 02:40 出处:网络
I have a list of objects. I need all possible permutations of those objects. In C++, there\'s std::next_permutation(). I have been trying to find something in the .NET Framework, but came up dry.

I have a list of objects. I need all possible permutations of those objects.

In C++, there's std::next_permutation(). I have been trying to find something in the .NET Framework, but came up dry.

开发者_JAVA百科

What am I missing?


I don't think it's built in to the framework but there's a good article on CodeProject with some samples

http://www.codeproject.com/KB/recipes/Combinatorics.aspx


I also think that there is no permutations() function included in the .NET Framework. But you could always go and implement it yourself...

...in that case you might find this post useful:

Fast permutation -> number -> permutation mapping algorithms

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号