Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 4 - Huffman Trees (Part 1)
Date: Tue Oct 9 2001 10:43 am
Author: Maxim, Michael G. <mmaxim@andrew.cmu.edu>
Subject: Re: little more info about storing bitstrings in ints

William,

You can easily store a bitstring in a Vector of ints. Each element of the Vector is an int, either 0 or 1, and you can pass these ints to FileBitWriter.writeBit() which will take the int 0 or 1 and write it to the file as a bit (not as an int or char).

Now keep in mind it does not actually write the bit, it queues up bits in consecutive calls to writeBit() until it has built up 8 bits, and writes those bits as a byte. But you don't have to worry about that until you get to the end of your compressed data and call the final writeBit(). After the final writeBit() make sure to call FileBitWriter.flush() to ensure that all bits are written to the file.

Mike
Post response

Go to the previous messageGo to the following message
Current Thread Detail:
little more info about storing bitstri...      Liu, William Y.      Tue Oct 9 2001 12:10 am       
Re: little more info about storing ...      Bortz, Andrew S.      Tue Oct 9 2001 12:38 am       
Re: little more info about storing ...      Maxim, Michael G.      Tue Oct 9 2001 10:43 am       
Comp. and DeComp. Speed issues      Yin, Hongxi      Wed Oct 10 2001 1:45 am       
Re: Comp. and DeComp. Speed i...      Maxim, Michael G.      Wed Oct 10 2001 4:25 pm       
Re: Comp. and DeComp. Speed i...      Lee, Charles C.      Wed Oct 10 2001 5:03 pm       
Re: Comp. and DeComp. Spee...      Cipriani, Jason A.      Thu Oct 11 2001 11:07 am       
Re: Comp. and DeComp. S...      Lee, Charles C.      Thu Oct 11 2001 3:17 pm       
Re: Comp. and DeComp...      Cipriani, Jason A.      Fri Oct 12 2001 1:51 am       

Back to previous screen