I was wondering how I can save space writing a bitset to a file ( probably using iostream) in c++. Will breaking up the bitset into bitset of size 8 and then writing each individual bitset to the file save me space? What is your thought about this. This is the intention of data compression.
Save space writing bitset to a file in C++
1.6k views Asked by DogDog At
2
There are 2 answers
0

If you use boost::dynamic_bitset
instead, you can specify the type of the underlying blocks and retrieve them with to_block_range
and from_block_range
functions.
http://www.boost.org/doc/libs/1_46_0/libs/dynamic_bitset/dynamic_bitset.html#to_block_range
(for example, use unsigned char
as block type and store them in a stream in binary mode)
Related Questions in C++
- No templates in Visual Studio 2017
- Xamarin.iOS on the Mac Server is not compatible
- NuGet Console in visual studio 2017 RC won't Add-Migration or Update-Database?
- VS2017 RC Web deploy - ERROR_CERTIFICATE_VALIDATION_FAILED
- How to use an ASP.NET Core environment variable in testing with Visual Studio
- How to create F# .Net Core ConsoleApp in Visual Studio 2017 RC
- Can I suppress a specific C6031 warning? CString::LoadString
- InterlockedExchange issue with C28112/3
- AppSettings.*.json files not copied on Publish in ASP.NET CORE 1.1
- Does Visual Studio 2017 Community create a Services folder for Dependency Injection with Core 1.0?
Related Questions in IOSTREAM
- No templates in Visual Studio 2017
- Xamarin.iOS on the Mac Server is not compatible
- NuGet Console in visual studio 2017 RC won't Add-Migration or Update-Database?
- VS2017 RC Web deploy - ERROR_CERTIFICATE_VALIDATION_FAILED
- How to use an ASP.NET Core environment variable in testing with Visual Studio
- How to create F# .Net Core ConsoleApp in Visual Studio 2017 RC
- Can I suppress a specific C6031 warning? CString::LoadString
- InterlockedExchange issue with C28112/3
- AppSettings.*.json files not copied on Publish in ASP.NET CORE 1.1
- Does Visual Studio 2017 Community create a Services folder for Dependency Injection with Core 1.0?
Related Questions in BITSET
- No templates in Visual Studio 2017
- Xamarin.iOS on the Mac Server is not compatible
- NuGet Console in visual studio 2017 RC won't Add-Migration or Update-Database?
- VS2017 RC Web deploy - ERROR_CERTIFICATE_VALIDATION_FAILED
- How to use an ASP.NET Core environment variable in testing with Visual Studio
- How to create F# .Net Core ConsoleApp in Visual Studio 2017 RC
- Can I suppress a specific C6031 warning? CString::LoadString
- InterlockedExchange issue with C28112/3
- AppSettings.*.json files not copied on Publish in ASP.NET CORE 1.1
- Does Visual Studio 2017 Community create a Services folder for Dependency Injection with Core 1.0?
Related Questions in COMPRESSION
- No templates in Visual Studio 2017
- Xamarin.iOS on the Mac Server is not compatible
- NuGet Console in visual studio 2017 RC won't Add-Migration or Update-Database?
- VS2017 RC Web deploy - ERROR_CERTIFICATE_VALIDATION_FAILED
- How to use an ASP.NET Core environment variable in testing with Visual Studio
- How to create F# .Net Core ConsoleApp in Visual Studio 2017 RC
- Can I suppress a specific C6031 warning? CString::LoadString
- InterlockedExchange issue with C28112/3
- AppSettings.*.json files not copied on Publish in ASP.NET CORE 1.1
- Does Visual Studio 2017 Community create a Services folder for Dependency Injection with Core 1.0?
Related Questions in LOSSLESS-COMPRESSION
- No templates in Visual Studio 2017
- Xamarin.iOS on the Mac Server is not compatible
- NuGet Console in visual studio 2017 RC won't Add-Migration or Update-Database?
- VS2017 RC Web deploy - ERROR_CERTIFICATE_VALIDATION_FAILED
- How to use an ASP.NET Core environment variable in testing with Visual Studio
- How to create F# .Net Core ConsoleApp in Visual Studio 2017 RC
- Can I suppress a specific C6031 warning? CString::LoadString
- InterlockedExchange issue with C28112/3
- AppSettings.*.json files not copied on Publish in ASP.NET CORE 1.1
- Does Visual Studio 2017 Community create a Services folder for Dependency Injection with Core 1.0?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
If you normally write one byte per bit in the bitset, then yes, storing eight elements to a byte will save you 7/8 of the space in the limit (you will have to store the size of the bitset somewhere, of course).
For example, this writes a
bitset
using one character per bit (7/8 overhead):while this stores it optimally compact (if we disregard padding at the end):
Note that
uint8_t
is not standard C++03. It resides in C99's<stdint.h>
or C++0x's<cstdint>
. You can also use anstd::bitset<8>
if you want.