Shuffle a GList ?



Hi,

How can I randomly shuffle the elements in a linked list? There is no
implemented method for this, is it?

The first thing I think of is: for each element, pick another an other
element and swap these two. But since I do not have random access to the
elements in the linked list this becomes a O(n2) algorithm, doesn't it?

-Øystein

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]