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