DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Require code for shuffling a list

  1. #1
    Join Date
    May 2005
    Posts
    33

    Red face Require code for shuffling a list

    Hi,
    I created a general list, having as a data member a pointer to the first node, and then linking all other nodes to the first node. My simulation program requires the list to be shuffled. I wonder if anyone can suggest (or even provide the code) how I might rearrange the contents of the list in a random fashion?
    I would be extremely grateful for all help.

  2. #2
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    MSDN have a function Random_Shuffle for the a vector data structure..
    http://msdn.microsoft.com/library/de...estlsample.asp

    Do you "have" to use a list?

  3. #3
    Join Date
    Jan 2005
    Location
    UK
    Posts
    604
    use std::random_shuffle works for lists/vectors/...

  4. #4
    Join Date
    Nov 2003
    Posts
    4,118
    std::random_shuffle is discussed here. http://www.devx.com/DevX/LegacyLink/9467
    Pelase note that the default shuffle algorithm uses a pseudo random shuffling. You can override this by plugging in a custom generator as the third argument.
    Danny Kalev

Similar Threads

  1. Control Arrays in VB.NET
    By Gary Nelson in forum .NET
    Replies: 277
    Last Post: 10-01-2003, 12:00 AM
  2. VS.Net and Code Behind
    By Chaitanya Marvici in forum ASP.NET
    Replies: 6
    Last Post: 07-21-2003, 09:15 AM
  3. Why integer and int32
    By Michael Culley in forum .NET
    Replies: 154
    Last Post: 05-10-2002, 12:06 PM
  4. Replies: 0
    Last Post: 04-11-2002, 06:48 PM
  5. wot is CLR
    By lostguy in forum .NET
    Replies: 8
    Last Post: 04-03-2002, 07:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center