Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2006-10-20 16:23:41


On 10/17/06, Markus Bernhardt <Markus.Bernhardt_at_[hidden]> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I have a custom vector-like template class for scalar types which
> compresses the contents similar to the infamous vector<bool> template.
>
> If for example all stored values are in the range from 0 to 1023 then
> only 10 bits will be used to store each value. If you insert the value
> 1024 to the sequence the bitcount will be increased to 11 and the whole
> sequence get rewritten.
>
> Now I want to use boost::iterator to create a "random access traversal
> iterator". I think I have to provide a custom Difference parameter,
> because std::ptrdiff_t will not work (right?).

ptrdiff_t will work. the difference between element #5 and element #10 is
still 5. It may be some other number of BYTES + BITS away, but 'difference'
measures the distance in number of elements, not number of bytes.

Or are you worried that ptrdiff_t isn't big enough? (ie a container with 2
bits/element could have more than 2^32 elements in a 32 bit system, and thus
ptrdiff_t is too small).

I have simply no idea how to do that.

The hard part, I think, is internally keeping track of where you *really*
are (pointer + bit offset).

Tony

Any comments are welcome.
>
> Thank you,
> Markus
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFFNLIUdnooMonJSYkRAi3dAJ91CwtdgBRdjDnt0gFKxvh0Hq7WVwCfUST/
> kpFy9EA5MGZvU1cF7RKnjZw=
> =c53t
> -----END PGP SIGNATURE-----
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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