Discussion:
question on lab 4
(too old to reply)
Rory Garand
2005-11-16 19:50:18 UTC
Permalink
hi.. i am testing lab4 and running into a problem defining a partial
map. the problem occurs when the program calls..

m[id].Define(d,r);

i get an error telling me that using the operator [] is illegal since
self is equal to the empty set. does this just mean that i have an
incorrect implementation of operator []?

thanks,
rory
Wayne D. Heym
2005-11-16 21:05:53 UTC
Permalink
Post by Rory Garand
the problem occurs when the program calls..
m[id].Define(d,r);
i get an error telling me that using the operator [] is illegal since
self is equal to the empty
probably "string" here, not "set"
Post by Rory Garand
set.
Because the test driver (as we gave it to you) tests a checking version,
when you test Define, you are actually having your Is_Defined operation
called before your Define operation gets called. Check the calling
trace that comes out before the violated assertion message to see which
operations are getting called along the way to violating this precondition.

Very likely the defect is in your Is_Defined operation. If the bucket
is the empty queue, then we should not call Move_To_Front on it and
return the result of testing equality with the current pair in the
queue, we should simply return false in that case. See
Partial_Map_Kernel_1_Body.h for a further hint on this problem.

For better debugging (but less robust testing), you may wish to change
the test driver (or make a new version of it) so that it instantiates
Partial_Map_Kernel_2a, and not Partial_Map_Kernel_2a_C.
--
Wayne
Loading...