On May 31, 2006, at 22:21 UTC, John Kubie wrote:
> I have a set of structures that may have one or several blobs
> associated with each. Each structure has a name and each blob has a
> unique number. I start with a list of name-blob number pairs. Names
> may or may not be unique. I want to end with a list where each name
> is present once and is associated with all of its blob numbers.
OK, sounds like you need a dictionary where the key is a name, and the value is
a set of blob numbers.
Unfortunately, you can't directly store an array as a dictionary value, because
arrays are not objects. So you'd have to use an array wrapper, or use
something other than an array (like another dictionary or a string).
Here's a simple solution that builds a comma-delimited list of blob numbers as
a string associated with each name -- assume 'name' and 'blobNumber' are the
pair that we want to add, and 'dict' is the dictionary holding all this data:
if dict.HasKey( name ) then
dict.Value( name ) = dict.Value( name ) + "," + str(blobNumber)
else
dict.Value( name ) = str(blobNumber)
end if
It's simple, but it works.
Best,
- Joe
--
Joe Strout -- [EMAIL PROTECTED]
Verified Express, LLC "Making the Internet a Better Place"
http://www.verex.com/
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>