On 18/01/2007, at 3:53 PM, Tom Benson wrote:
Each block of data will be represented by a class object by my
framework, so I'd like to instantiate only one object and pass it
byref to the parts of the program that will be working with it.
Do you really mean ByRef in the RB sense or as a reference, which of
course all objects are passed as?
ie: will the things working with it send back a different object?
This is easy enough, as each block has a unique signature, so I've
set up a dictionary to store the single instance keyed against that
data blocks unique id.
Unless the lookups are very very frequent, you will still get a
fairly efficient lookup from a string storing the hex representation
of the object ID.
off the top of my head:
dim v as variant = myObject
dim id as integer = v.integerValue ' we now have the unique ID
dim theKey as string = Hex(id) ' string representation has no link
to the object, so no effect on reference count
I would put the above into an extends method on Object, so you can
use it any time.
We used string keys in an Object layer in a c++ program talking to
the MS SQL engine. It was plenty fast enough for dealing with
hundreds of objects when doing lookups to see if things were cached.
_______________________________________________
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>