Filtering array vs plain list

Shari shari at gypsyware.com
Fri Feb 1 23:35:58 EST 2008


I've never worked with intersecting arrays, so please pardon the questions.

If I understand your example, I'd have something like this:

birthYear[1976] = John Jones,Billy Bob,Mary Lou,Manny Mack,Barbie Doll
birthYear[1977] = Ellie May,Carrie Ann,Andy Ant,Donna Mills,Jackie O
baseballTeam[Red Sox] = Billy Bob,Manny Mack
baseballTeam[White Sox] = Barbie Doll,Ellie May

This would produce about 300 arrays.  The [] keys would be virtually 
unlimited.  There might be a couple hundred birthYears for example.

If I wanted to get all census data for Billy Bob, I'd do a repeat 
loop for each key of each of the 300 arrays to get all info 
pertaining to Billy Bob?  I had not thought of that approach.  It's 
fast?

To get a list of all Red Sox fans born in 1976, I'd just need to 
intersect the two array/key combos?

Looking for all data on Billy Bob will happen more frequently than 
looking for all Red Sox fans born in 1976.  And it will be common to 
delete Billy Bob from all arrays, or add Billie Jean.  Most of the 
time the primary reference would be to Billy Bob, such as "What is 
Billy Bob's baseball team?" Does that change it?

Note that this is not for a database, but for a game where I need to 
track thousands of people each having about 300 pieces of info 
defining them, the defining info will change constantly, and changes 
need to be instantaneous.

Shari





>Hi, Shari.  There are other ways to structure your data that can make your
>"glitch" easier to handle.  Choosing the best way depends on various
>factors, such as:
>1) time constraints on adding, updating, and deleting people, properties,
>and values
>2) whether you have multiple simultaneous users
>3) your time and skills
>
>But jumping the gun, you could consider using arrays like the following:
>
>birthYear[1976] = 5489
>baseballTeam["Red Sox"] = 3258
>eyeColor["blue"] = 5489 & cr & 3258
>
>Then evaluating your compound example involves retrieving the values of
>baseballTeam["Red Sox"] and birthYear[1950], deriving the intersection of
>those values, removing them from baseballTeam["Red Sox"], and inserting them
>into baseballTeam["White Sox"].
>
>I've used this approach; it's fast.  I'd be glad to help you further if
>you're interested.
>
>-- Dick


-- 
WlND0WS and MAClNT0SH shareware games
BIackjack GoId
http://www.gypsyware.com



More information about the use-livecode mailing list