[Cs3] Lab 7, Hash maps

Mikhail Nesterenko mikhail at cs.kent.edu
Fri Feb 28 11:33:39 EST 2020


> 
> I have a question about Lab 7. On the description of the lab it says that
> "returns a pair: <pointer, result>, where pointer is a pointer to the newly
> inserted value or the old value with the same key result is a boolean value
> which is true if the element is inserted" what does this mean for the
> return type? Yesterday during Alfred's lab you said that it should
> return pair<pair<const
> Key, Value>*, bool> but a number of students have come into tutoring with
> insert returning pair<Value*, bool>. Could you clear up this confusion?

It should return a pair:
- a (C-style) pointer to the element and
- a boolean result - true or false depending whether insert was
  successful. 

It should not return an integrator because we are not implementing
iterators for this hashmap. To obtain a pointer to return, use the
technique similar to what is used on line 132 in file hashmap.hpp:
dereference the iterator and then take the address of the obtained
element.

Thanks,
-- 
Mikhail


More information about the cs3 mailing list