Search the web
Sign In
New User? Sign Up
netlogo-users · NetLogo Users
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.

Messages

  Messages Help
Advanced
Need advice implementing associative array   Message List  
Reply Message #2354 of 10135 |
Re: [netlogo-users] Need advice implementing associative array


>>>>> "Jim" == Jim Lyons <jimlyons@...> writes:

Jim> I need what amounts to an associative array. As it happens, both
Jim> the key and value are short fixed length strings. My need is for
Jim> something that will perform well with roughly 2000 entries. About
Jim> 10 to 20 agents will have their own lists and will be using them
Jim> constantly.

I agree with James' answer. If it's annoying to have to juggle two
variables instead of one, you could put both lists inside a single list,
at only a very small cost to efficiency:

[ [k1 k2 ...] [v1 v2 ...] ]

I assume you are primarily concerned with efficiency of lookup rather
than efficiency of update? If you need to be constantly updating the
entries, I'm not sure any solution will be fast unless you write some
Java code using the extensions API.

Jim> It also happens that the strings are all digits. Would it be
Jim> better to convert them to numbers and store and retrieve them that
Jim> way? I would have to convert them back to strings (or digits) for
Jim> use. Do all numbers, even small integers, take up 8 bytes each? If
Jim> so, it seems strings would be the way to go.

I would expect the strings to be both more compact and faster.

--
Seth Tisue / seth@... / (847) 467-2814
lead developer, NetLogo http://ccl.northwestern.edu/netlogo/
Center for Connected Learning and Computer-Based Modeling
School of Education and Social Policy / Department of Computer Science
Northwestern University






Fri Nov 5, 2004 9:26 pm

sethtisue
Offline Offline
Send Email Send Email

Message #2354 of 10135 |
Expand Messages Author Sort by Date

I need what amounts to an associative array. As it happens, both the key and value are short fixed length strings. My need is for something that will perform...
Jim Lyons
jimlyons37
Offline Send Email
Nov 5, 2004
4:22 am

... There is at least one other way, and that is to use two lists. key-list --> [ k1 k2 k3 k4 ] value-list --> [ v1 v2 v3 v4 ] to-report dict-item [ key ] ...
James Steiner
jps_netlogo
Offline Send Email
Nov 5, 2004
1:50 pm

... Jim> I need what amounts to an associative array. As it happens, both Jim> the key and value are short fixed length strings. My need is for Jim> something...
Seth Tisue
sethtisue
Offline Send Email
Nov 5, 2004
9:32 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help