swarm-support
[Top][All Lists]
Advanced

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

Collections need: Array Map?


From: Paul Johnson
Subject: Collections need: Array Map?
Date: Wed, 01 May 2002 09:11:45 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020326

I have agents who wander around, encounter things, and make a note of the source of the "thing" and they create a "record" object to summarize what they found. WHen they come to the thing again, they update the record.

I'm keeping the records in a map, using a string from the thing as the key.

Now the question my colleague asks is, "can you give me the 3 most recently altered (created/updated) records."

I've stared at this a long time and all of the scenarios I dream up seem horribly cloddish. For example, create a new Swarm List to hold keys for the most recently encountered things (records). When you meet/update a record, search to see if the List contains that key already. If so remove it, and addFirst that record's key. If the List does not yet have that key, then remove the Last item (assuming there are 3 or more) and then addFirst the new key. Blah.

So, before I go and do such a cloddish thing, I am asking if there is a more elegant approach, because there usually is.

--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700


                 ==================================
  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]