Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 4 - Huffman Trees (Part 1)
Date: Wed Oct 10 2001 1:01 am
Author: Cipriani, Jason A. <jac4@andrew.cmu.edu>
Subject: Re: general clarification on FileBitReader/Writer classes

we all know by now that you can use readBits(8). the big difference between readByte() and readBits(8) isn't so much the return type as the implementation of it. readByte() calls FileInputStream.read(), while readBits does that little loop. readByte() is approximately 12% faster than readBits(8) on my own machine.

the big advantage to readBits(8) (besides the unsigned return type) is that the stuff doesn't necessarily need to be byte aligned to read it correctly.

the return type "byte" IS a bad choice. because of the fact that it is unsigned, it is a bad choice. "char" is far more appropriate from reading characters from a file. not only can it hold values in the range 0 to 255, but is two bytes long and thus has support (even though we don't need it for this assignment) for wider character sets.
Post response

Go to the previous messageGo to the following message
Current Thread Detail:
general clarification on FileBitReader...      Liu, William Y.      Mon Oct 8 2001 10:34 pm       
Re: general clarification on FileBi...      Lee, Charles C.      Mon Oct 8 2001 11:13 pm       
Re: general clarification on Fil...      Cipriani, Jason A.      Mon Oct 8 2001 11:30 pm       
Re: general clarification on ...      Bortz, Andrew S.      Tue Oct 9 2001 12:28 am       
Re: general clarification ...      Cipriani, Jason A.      Wed Oct 10 2001 1:01 am       
Re: general clarificati...      Bortz, Andrew S.      Wed Oct 10 2001 11:04 am       
Re: general clarific...      Cipriani, Jason A.      Wed Oct 10 2001 12:45 pm       
Re: general clarific...      Cipriani, Jason A.      Wed Oct 10 2001 12:50 pm       
Re: general clari...      Cipriani, Jason A.      Wed Oct 10 2001 12:51 pm       

Back to previous screen