c# - What data structure can I use to access its contents randomly? -


i need add bunch of items data structure , later access of items within in random order. how can this?

to more specific, adding urls list<string> object. added in way such adjacent urls on same server. when access list using parallel.foreach statement, returns items in order added them. okay, when making web requests in parallel, tends overwhelm servers , leads timeouts. data structure can use return items in more random way when run parallel.foreach statement on object (i.e., not in order added them)?

original solution

fisher–yates shuffle

public static void shuffle<t>(this ilist<t> list)   {       random rng = new random();       int n = list.count;       while (n > 1) {           n--;           int k = rng.next(n + 1);           t value = list[k];           list[k] = list[n];           list[n] = value;       }   }  list<product> products = getproducts(); products.shuffle(); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -