I need a way to add arrays containing single bits to a buffer.
Has someone any good ideas on how to represent an array of bits and how to represent a buffer for it. The length of an array may change from 1 to 17 bits. I also need to be able to read n bits from a buffer.
/Fredrik
Thanks Estor!
Looks like I can steal som ideas from that.
This is what I like about the gamedev forum. You can spend hours at google and then there''s always someone in here who can point you to what you really want.
Looks like I can steal som ideas from that.
This is what I like about the gamedev forum. You can spend hours at google and then there''s always someone in here who can point you to what you really want.
yeah, use std::vector<bool> (#include <vector> - it contains a specialisation for bools that packs the bits into a char array.
The STL thing is a template?
If it is, then it would probably be really slow.
Not that it matters for my purpose but anyway.
If it is, then it would probably be really slow.
Not that it matters for my purpose but anyway.
quote:Original post by Fredrik Dahlberg
The STL thing is a template?
If it is, then it would probably be really slow.
Not that it matters for my purpose but anyway.
Gah, that''s BS. They''re just as fast at run-time as regular code. And it''s
bitset
you want to look into. Really cool class.
quote:Original post by Fredrik DahlbergI believe templated code is generated during compile time, so like Zipster said, it''s just as fast as regular code. For example:
The STL thing is a template?
If it is, then it would probably be really slow.
Not that it matters for my purpose but anyway.
template < typename T >class Blah{ T test;};Blah< int > BlahInt;// will generate:// class Blah// {// int test;// };Blah< MyClass > BlahClass;// will generate:// class Blah// {// MyClass test;// };
so it''s like having the compiler to write code for us, we only need to give them the template.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement