Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-01-04 08:26:18

"Wyss, Felix" <FelixW_at_[hidden]> writes:

>> > I think it would be better to mandate that resize()
>> > 1) guarantees iterators remain valid
> [Wyss, Felix] I would argue that resize() is semantically an invariant
> operation on a hash table; it doesn't modify the content.
> It's an operation to adjust the memory consumption and lookup
> performance tradeoff at runtime.

Just like std::vector<T>::reserve? Should that guarantee that
iterators remain valid and not throw exceptions?

> As a previous poster pointed out,
> the SGI implementation guarantees that iterators remain valid.
>> > 2) provides the strong exception guarantee
> [Wyss, Felix] Same here, resize() is a semantically invariant operation.

I don't see why that should have any bearing.

> It's easy to implement a hash table that provides the strong exception
> guarantee for resize() by caching the hash code.
> This even increases performance for types with expensive compares.
> I thus dare asking: Why not?

It incurs a space cost that some people may not want to pay and
decreases performance for some types.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at