Boost logo

Boost Users :

From: Johnson, Donald W MVK Contractor (Donald.W.Johnson_at_[hidden])
Date: 2005-02-08 15:33:50


In your example

size() returns 4
capacity() returns 6
end() returns a pointer to the 5th element

When in doubt about standard container design examing std::vector is a good
place to start.

Good Luck
  

-----Original Message-----
From: Foster, Gareth [mailto:gareth.foster_at_[hidden]]
Sent: Tuesday, February 08, 2005 8:36 AM
To: 'boost-users_at_[hidden]'
Subject: [Boost-users] Custom containers

Hello all,

If you were to write a container that had a certain size, say 6, but may not
always contain 6 items, say it contains 4, what would it be best to have the
following methods do?

size() - returns 6 or 4?
end() - returns an iterator on the 5th or 7th element?

I'm not sure if the standard way of writing such things dictates a certain
approach, or if it is purely down to the intended use.

Thanks for any information.

Gaz

*******************************
* http://planetearthworm.com/ *
*******************************


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net