简体   繁体   English

很大列表排序的内存置换随机linq

[英]memory permutation random linq of very large list orderby

I am doing a permutation of a specific series of sequences that is 104 characters long. 我正在对104个字符长的特定序列序列进行排列。 I was using plinq to generate the sequence but without a random order the results are never complex enough to be selected. 我使用plinq生成序列,但是没有随机顺序,结果永远不会复杂到无法选择。

The problem is orderby with rnd.next and guid.newguid fills up memory and returns no results. 问题是rnd.next和guid.newguid的orderby填满了内存,没有返回结果。

is there any solution to randomly selecting from a linq pattern in C#? 有什么办法可以从C#的linq模式中随机选择?

var query = 
             from sp1 in polar
                    ...
             from vp15 in polar                           
             where GetCompressionRatio(sp1+...+vp15)>1.5
             orderby rnd.Next(0, 100000000) * rnd.Next(0, 100000000)
             select sp1+...+vp15;


foreach (var element in query)
{
    //output
}

You are trying to solve two very different problems with the same query. 您正在尝试使用同一查询解决两个非常不同的问题。 Even if there is a clever way to do it, I would suggest you take it one step at a time. 即使有聪明的方法,我还是建议您一次迈出一步。

First, generate a non random permutation. 首先,生成一个非随机排列。 Than, apply some random permutation algorithm on the previous result. 然后,对先前的结果应用一些随机置换算法。 You can try the very simple Knuth Shuffle . 您可以尝试非常简单的Knuth Shuffle

Your intention will be much more clear and the decomposition can give you significant advantages in testing and debugging. 您的意图将更加清楚,分解可以为您提供测试和调试方面的显着优势。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM