swarm-support
[Top][All Lists]
Advanced

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

Re: java indexes


From: Nick Collier
Subject: Re: java indexes
Date: Fri, 15 Dec 2000 10:41:53 -0600

On Friday 15 December 2000 10:25, you wrote:
> 
> This may be naive.  I get the idea from listening to the talk among the
> Java Swarm users that one should use the Java collections instead of
> Swarm collections, but this capability for random transversal seems
> necessary on the Java side.   Is there some comparable Java library or
> package that will let me transverse a Java collection in random order?  

java.util.Collections has two static methods - Collections.shuffle(List list) 
and Collections.shuffle(List list, Random rnd).

You could use it as follows:

ArrayList list = new ArrayList();
list.add(someObj);
(add some more objects)

...

Collections.shuffle(list);

or

Collections.shuffle(list, new Random(someSeed));

I don't know if java.util.Random is tied into Swarm at all (i.e. if one of 
Sven's generators could be used here), so its perhaps not useful if you want 
repeatable predictable randomness.

You can perform lots of operations on lists with the Collection class 
(sorting, some searching, etc.), and anybody using Java should become familar 
with it.

Nick

-- 
Nick Collier
Social Science Research Computing
University of Chicago
http://repast.sourceforge.net

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]