digitalmars.D - ? key in AssociativeArray
- Thomas Kuehne (34/34) Dec 06 2004 -----BEGIN PGP SIGNED MESSAGE-----
- Regan Heath (26/51) Dec 06 2004 If you are, so am I. :)
- Simon Buchan (11/35) Dec 06 2004 "InExpressions now, instead of returning a bit, return a pointer to the
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 code: output: According to the docu ptr should be pointing to the value or NULL. PTR is pointing to NULL if the key isn't present in the array - but where is it pointing to if the key is present? Am I missing something? Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.13 (GNU/Linux) iD8DBQFBtDbN3w+/yD4P9tIRAhClAKDKQfFnreY4xVlTAGzi4a8N38PVjQCeNjRW ob5F5v6SXTBhM3aCUWhNkLQ= =vJ+R -----END PGP SIGNATURE-----
Dec 06 2004
On Mon, 6 Dec 2004 11:39:10 +0100, Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> wrote:code: output: According to the docu ptr should be pointing to the value or NULL. PTR is pointing to NULL if the key isn't present in the array - but where is it pointing to if the key is present? Am I missing something?If you are, so am I. :) D:\D\src\temp>keyin &value: 12ff18 1 &array[key]: 870fd4 1 ptr: 870fd0 4264064 ptr: 870fd4 1 The first thing I thought was, when you add an 'int' to an array it copies the int creating a new one, so &value wont == &array[key], BUT, ptr should == &array[key]. My results seem to show that it's out by 4 bytes, 32 bits, or 1 int. Regan
Dec 06 2004
On Tue, 07 Dec 2004 09:04:28 +1300, Regan Heath <regan netwin.co.nz> wrote: <snip>If you are, so am I. :) D:\D\src\temp>keyin &value: 12ff18 1 &array[key]: 870fd4 1 ptr: 870fd0 4264064 ptr: 870fd4 1 The first thing I thought was, when you add an 'int' to an array it copies the int creating a new one, so &value wont == &array[key], BUT, ptr should == &array[key]. My results seem to show that it's out by 4 bytes, 32 bits, or 1 int. Regan"InExpressions now, instead of returning a bit, return a pointer to the associative array element if the key is present, null if it is not." Looks like Walter forgot to check it. Looks like an implementation thing, like it points to the hash of the key or something. 0x00411080 (*ptr in hex) does look like a string literal hash... -- "Unhappy Microsoft customers have a funny way of becoming Linux, Salesforce.com and Oracle customers." - www.microsoft-watch.com: "The Year in Review: Microsoft Opens Up"
Dec 06 2004