MOAB: Mesh Oriented datABase
(version 5.2.1)
|
00001 #include "BitPage.hpp" 00002 #include "moab/Range.hpp" 00003 #include <stdlib.h> 00004 #include <string.h> 00005 00006 namespace moab 00007 { 00008 00009 void BitPage::search( unsigned char value, int offset, int count, int per_ent, Range& results, 00010 EntityHandle start ) const 00011 { 00012 const int end = offset + count; 00013 Range::iterator hint = results.begin(); 00014 while( offset != end ) 00015 { 00016 if( get_bits( offset, per_ent ) == value ) hint = results.insert( hint, start ); 00017 ++offset; 00018 ++start; 00019 } 00020 } 00021 00022 BitPage::BitPage( int per_ent, unsigned char init_val ) 00023 { 00024 unsigned char mask = (unsigned char)( 1 << per_ent ) - 1; // 2^per_ent - 1 00025 init_val &= (unsigned char)mask; 00026 switch( per_ent ) 00027 { 00028 default: 00029 assert( false ); 00030 abort(); 00031 break; // must be power of two 00032 // Note: no breaks. fall through such that all bits in init_val are set 00033 case 1: 00034 init_val |= (unsigned char)( init_val << 1 ); 00035 case 2: 00036 init_val |= (unsigned char)( init_val << 2 ); 00037 case 4: 00038 init_val |= (unsigned char)( init_val << 4 ); 00039 case 8:; 00040 } 00041 memset( byteArray, init_val, BitTag::PageSize ); 00042 } 00043 00044 } // namespace moab