Doesn't sound too tough to write your own algorithm.  For
example you can iterate through your array and swap each 
element in turn with another randomly chosen element.

If the elements are large, it will be helpful (faster) to
build an array of pointers to the elements in the main 
array, and then just shuffle that.

Details are left as an exercise for the reader.  :-)

-- Rod
   http://www.sunsetsystems.com/

On Monday 25 November 2002 11:05 am, Alexandra Thorn wrote:
> I've been looking around for a C library function that will shuffle the
> elements of an arbitrarily long array.  I'd been hoping to turn up
> something that would randomly shuffle the elements of an array.  The array
> that I want to shuffle is made up of a class of structs that I've created.
>
> A few hours of googling and fiddling with the man pages hasn't shed too
> much light on the issue: the closest I've found was strfry, which is
> supposed to randomize the order of a string.  I'm still a newbie, though,
> so maybe don't know where to look.
>
> I suppose that I might be able to hack something up to randomize the order
> of an array by using strfry to scramble an array of chars corresponding to
> indices, but wanted to check if there is a better way to do this.

_______________________________________________
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech

Reply via email to