Ask the Expert

Pack attributes to reduce space

I have the following attribute in my class

bool a [12];
bool b [100];
bool c [200];

All the attributes are boolean arrays. I have to pack them to reduce space. Is it possible in C++ (I know it is possible in ADA), if so please let me know how I can achieve that.


Looking at your example, it's not easy to imagine an alternative structure that would be more efficient and faster for processing than what you have.

If you had LARGE data sets that are sparsely populated, you could use a table with a 2 part key and a value. (Example: key = boola + index, value = 1 or 0)

==================================
MORE INFORMATION ON THIS TOPIC
==================================

Ask your Web development questions--or help out your peers by answering them--in our live discussion forums.

The Best Web Links: tips, tutorials and more.

Check out this live Q&A with Dave Slater and Jim Mason, How to best get started with WebSphere Development Tools.


This was first published in October 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: