Total members 11890 |It is currently Sat Apr 20, 2024 6:41 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





1.A bit vector is a vector with binary elements, that is, each element is either a 0 or a 1. Small bit vectors are conveniently represented by unsigned integers. For example, an unsigned char can represent a bit vector of 8 elements. Larger bit vectors can be defined as arrays of such smaller bit vectors. Complete the implementation of the Bitvec class, as defined below. It should allow bit vectors of any size to be created and manipulated using the associated operators.
Code:
    
enum Bool 
{falsetrue};  
typedef unsigned char uchar;    
class 
BitVec {  
public:     
BitVec       (const short dim);     
BitVec       (const charbits);     
BitVec       (const BitVec&);     
~
BitVec    (void)       
 { 
delete vec
}     
BitVecoperator =    (const BitVec&);     
BitVecoperator &=   (const BitVec&);
BitVecoperator |=   (const BitVec&);    
BitVecoperator ^=   (const BitVec&);    
BitVecoperator <<=  (const short);     
BitVecoperator >>=  (const short);    
 
int    operator []    (const short idx);     
void   Set       (const short idx);     
void   Reset        (const short idx);       
BitVec  operator ~    (void);     
BitVec  operator &    (const BitVec&);     
BitVec  operator |    (const BitVec&);    
 
BitVec  operator ^    (const BitVec&);    
 
BitVec  operator <<   (const short n);    
 
BitVec  operator >>   (const short n);     
Bool   operator ==   (const BitVec&);     
Bool   operator !=    (const BitVec&);     
friend ostreamoperator << (ostream&, BitVec&);    
private:     
uchar  *vec;        // vector of 8*bytes bits     
short   bytes;       // bytes in the vector  
};
 





Author:
Newbie
User avatar Posts: 1
Have thanks: 1 time

For this message the author vinoth1289 has received gratitude : DrRakha

code not clear :S :Blackeye:

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 




cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com