00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 #ifndef bitset_INCLUDED 00037 #define bitset_INCLUDED 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 /* ==================================================================== 00043 * ==================================================================== 00044 * 00045 * Module: bitset.h 00046 * $Revision: 1.1 $ 00047 * $Date: 2005/07/27 02:17:57 $ 00048 * $Author: kevinlo $ 00049 * $Source: /depot/CVSROOT/javi/src/sw/cmplr/common/util/bitset.h,v $ 00050 * 00051 * Revision history: 00052 * 05-01-93 - Original Version 00053 * 00054 * Description: 00055 * 00056 * Bitset interface. See below for details. 00057 * 00058 * ==================================================================== 00059 * ==================================================================== 00060 */ 00061 00062 00063 #ifdef _KEEP_RCS_ID 00064 static char *xxx_rcs_id = "$Source: /depot/CVSROOT/javi/src/sw/cmplr/common/util/bitset.h,v $ $Revision: 1.1 $"; 00065 #endif /* _KEEP_RCS_ID */ 00066 00067 /* This package implements sets of nonnegative INTs. These can be 00068 * manipulated with a fairly complete repertoire of set functions. 00069 * The sets are represented with bit strings for efficiency of both 00070 * space and run time. The vector that represents these sets is grown 00071 * as necessary to accommodate the results of the various operations. 00072 * In spite of this, the client of the package retains control over 00073 * storage allocation by providing memory allocation pools 00074 * (MEM_POOLs). The representations are never automatically trimmed, 00075 * so that the representation of any given bit set will be large 00076 * enough to hold the largest number that it ever held. 00077 * 00078 * 00079 * 00080 * Destructive Operations Conventions 00081 * ================================== 00082 * 00083 * 00084 * This package contains a number of functions that implement 00085 * destructive operations. The purpose of these operations is 00086 * efficiency both of the operations themselves and of memory usage. 00087 * Some of the destructive operations may still need to expand the 00088 * storage allocated to the set. When this happens, the set may need 00089 * to be copied. Thus you can not count on the side effects of these 00090 * operations, only on the correctness of their returned values. 00091 * Functions in this package that can have a destructive effect on a 00092 * one of their arguments always have a name that ends with the letter 00093 * D. Only the first argument of such functions is ever destructively 00094 * modified. All destructive operations return a pointer to the set. 00095 * In the normal case this will be the same as their first argument, 00096 * but sometimes the set will have to be copied in order to perform 00097 * the operation. So the client should not rely on the side effects 00098 * of destructive operations. Instead, one should use their returned 00099 * values. For now, destructive operations only expand storage, and 00100 * never shrink it. 00101 * 00102 * 00103 * Replacement Operations Conventions 00104 * ================================== 00105 * 00106 * 00107 * This package implements a number of "replacement" operations. 00108 * These are very similar to the "destructive" versions, but also take 00109 * a pointer to the result, which is not used in the calculation. 00110 * These all end with the letter R. 00111 * 00112 * 00113 * Storage Allocation 00114 * ================== 00115 * 00116 * 00117 * The client of this package has full control over storage allocation 00118 * for BS's. This is achieved by passing storage allocation pools 00119 * (MEM_POOLs) to the functions that may need to use them. All 00120 * storage allocated for a set is "flat", which is to say that from 00121 * the point of view of storage allocation, each BS may be seen as a 00122 * single array containing no pointers to additional storage. This 00123 * allows the client to free this storage directly if its allocation 00124 * pool supports freeing (See the discussion under BS_Create below). 00125 * 00126 * 00127 * 00128 * Types 00129 * ===== 00130 * 00131 * 00132 * TYPE struct bs BS 00133 * 00134 * This is the client visible type of a BS. It has no client 00135 * visible fields. 00136 * 00137 * 00138 * TYPE BS_ELT 00139 * 00140 * This is the type of an element of a BS. It is a numeric type 00141 * with the range 0..INT_MAX-1 00142 * 00143 * 00144 * Creation, Clearing, and Freeing 00145 * =============================== 00146 * 00147 * 00148 * BS *BS_Create( BS_ELT size, MEM_POOL *pool ) 00149 * 00150 * Creates and returns a new BS capable of holding (without 00151 * expansion) any set of integers in the range 0 through size - 1. 00152 * 'Size' must be nonnegative or an error is caused. The newly 00153 * created BS is uninitialized, and may contain any of the 00154 * possible sets. 'Pool' is used to allocate the space for the 00155 * set. Storage for the space is "flat", that is the set is 00156 * allocated as a single array and contains no pointers to any 00157 * additionally allocated memory. The client is thus free to free 00158 * the BS directly (if 'pool' supports this.) (the allocated size 00159 * may be obtained from BS_Alloc_Size). 00160 * 00161 * 00162 * size_t BS_Size_Alloc_Size( BS_ELT size ) 00163 * 00164 * Returns the number of bytes which would be required to allocate 00165 * a set of 'size' size, i.e., the minimum number of bytes required 00166 * to hold a set containing the elements 0 through size - 1. 00167 * 00168 * 00169 * size_t BS_Alloc_Size( BS *set ) 00170 * 00171 * Returns the number of bytes used to allocate the 'set'. 00172 * 00173 * 00174 * BS *BS_ClearD( BS *set ) 00175 * 00176 * Destructive clear operation. After this 'set' will be empty. 00177 * However, this does not change the allocated size of the set (it 00178 * will still be able to contain the same members that it could 00179 * before it was cleared without expansion.) 00180 * 00181 * 00182 * BS *BS_Create_Empty( BS_ELT size, MEM_POOL *pool ) 00183 * 00184 * Create an empty set large enough to hold the element 'size' - 1 00185 * without expansion. Equivalent to 00186 * 00187 * BS_ClearD( BS_Create( size ), pool ) 00188 * 00189 * 00190 * BS *BS_ResizeD( BS* set, BS_ELT new_size, MEM_POOL *pool ) 00191 * 00192 * Resize the set to be large enough to hold element 'new_size' - 1 00193 * without expansion. Similar to creating an empty set of the 00194 * new_size, and then copying the set to it. 00195 * 00196 * 00197 * BS *BS_Range( BS_ELT low, BS_ELT high, MEM_POOL *pool ) 00198 * BS *BS_RangeD( BS* set, BS_ELT low, BS_ELT high, MEM_POOL *pool ) 00199 * 00200 * Returns a set whose members are 'low' ... 'high'. Both 'low' 00201 * and the size of the range must be nonnegative or an error is 00202 * caused. I.e., 'low' >= 0 and ('high' - 'low' + 1) >= 0. Note 00203 * that 'high' may be -1 if 'low' is 0. 00204 * 00205 * 00206 * BS *BS_Singleton( BS_ELT element, MEM_POOL *pool ) 00207 * BS *BS_SingletonD( BS *set, BS_ELT element, MEM_POOL *pool ) 00208 * 00209 * Returns a set with 'element' as its sole member. 00210 * 00211 * 00212 * BS *BS_Universe( BS_ELT size, MEM_POOL *pool ) 00213 * BS *BS_UniverseD( BS *set, BS_ELT size, MEM_POOL *pool ) 00214 * 00215 * Returns a set containing 0...'size' - 1. 'Size' must be 00216 * nonnegative or an error is caused. 00217 * 00218 * 00219 * 00220 * Copying 00221 * ======= 00222 * 00223 * 00224 * BS *BS_Copy( BS *set, MEM_POOL *pool ) 00225 * BS *BS_CopyD( BS *set1, BS *set2, MEM_POOL *pool ) 00226 * 00227 * Returns an exact copy of set. Note that for BS_CopyD, if storage is 00228 * allocated it will be the same as the storage actually allocated to 00229 * set2, regardless of the current size of set2. Thus the following 00230 * sequence: 00231 * 00232 * BS *set1, set2; 00233 * set1 = BS_Create( 32, pool ); 00234 * set2 = BS_Create( 1024, pool ); 00235 * set2 = BS_ClearD( set2 ); 00236 * set1 = BS_CopyD( set1, set2, pool ); 00237 * 00238 * will result in set1 being grown to be large enough to contain 00239 * the integer 1023, even though it will be empty. 00240 * 00241 * 00242 * Set Operations 00243 * ============== 00244 * 00245 * 00246 * BS_ELT BS_Choose( BS *set ) 00247 * 00248 * Returns some element of 'set', if 'set' is nonempty. Else rerturns 00249 * BS_CHOOSE_FAILURE. In fact, this is defined so that it always 00250 * returns the least element of the set. 00251 * 00252 * 00253 * BS_ELT BS_Intersection_Choose( BS *set1, BS *set2 ) 00254 * 00255 * Returns some element of the intersection of 'set1' and 'set2', if 00256 * this intersection is nonempty. Else rerturns BS_CHOOSE_FAILURE. 00257 * In fact, this is defined so that it always returns the least 00258 * element of the set. 00259 * 00260 * 00261 * BS_ELT BS_Choose_Range( BS *set, BS_ELT low, BS_ELT high ) 00262 * 00263 * Returns some element of 'set' intersection {low...high} if 00264 * there is one. Else returns BS_CHOOSE_FAILURE. Both 'low' and 00265 * the size of the range must be nonnegative or an error is 00266 * caused. I.e., 'low' >= 0 and ('high' - 'low' + 1) >= 0. Note 00267 * that 'high' may be -1 if 'low' is 0. As with the _Choose 00268 * function, always returns the last element of the set that's in 00269 * range. 00270 * 00271 * 00272 * CONST BS_ELT BS_CHOOSE_FAILURE 00273 * 00274 * A special value that BS_Choose and BS_Choose_Range return when they 00275 * are unable to choose an element. 00276 * 00277 * 00278 * BS *BS_Difference( BS *set1, BS *set2, MEM_POOL *pool ) 00279 * BS *BS_DifferenceD( BS *set1, BS *set2 ) 00280 * 00281 * Returns { x : member( x, 'set1' ) & ~ member( x, 'set2' ) }. 00282 * 00283 * 00284 * BS *BS_Difference1( BS *set, BS_ELT x, MEM_POOL *pool ) 00285 * BS *BS_Difference1D( BS *set, BS_ELT x ) 00286 * 00287 * Returns { y : member( y , set ) & ~ ( y = x ) }. X must be 00288 * nonnegative or an error is caused. 00289 * 00290 * 00291 * BS *BS_Intersection( BS *set1, BS *set2, MEM_POOL *pool ) 00292 * BS *BS_IntersectionD( BS *set1, BS *set2 ) 00293 * BS *BS_IntersectionR( BS *result, BS *set1, BS *set2 ) 00294 * 00295 * Returns the intersection of 'set1' and 'set2'. 00296 * 00297 * 00298 * BS_ELT BS_Size( BS *set ) 00299 * 00300 * Returns the cardinality of 'set'. 00301 * 00302 * 00303 * BS *BS_Union( BS *set1, BS *set2, MEM_POOL *pool ) 00304 * BS *BS_UnionD( BS *set1, BS *set2, MEM_POOL *pool ) 00305 * BS *BS_UnionR( BS *result, BS *set1, BS *set2, MEM_POOL *pool ) 00306 * 00307 * Returns the union of set1 and set2. 00308 * 00309 * 00310 * BS *BS_Union1( BS *set, BS_ELT x, MEM_POOL *pool ) 00311 * BS *BS_Union1D( BS *set, BS_ELT x, MEM_POOL *pool ) 00312 * 00313 * Returns set union { x }. X must be nonnegative or an error is caused. 00314 * 00315 * 00316 * BS* BS_UnionD_Intersection( BS* set1, BS* set2, BS* set3, MEM_POOL* pool ) 00317 * 00318 * Destructively unions into set1 the intersection of set2 and set3, 00319 * growing it if necessary in the given pool. 00320 * 00321 * 00322 * BS *BS_2_1_Minus_3_Or_R(BS *result,BS *set1,BS *set2,BS *set3, MEM_POOL *pool) 00323 * 00324 * Returns result = ~set1 & set2 | set3 00325 * 00326 * 00327 * BS *BS_3_2_Minus_1_Or_D(BS *set1,BS *set2,BS *set3, MEM_POOL *pool) 00328 * 00329 * Returns set1 = ~set2 & set3 | set1 00330 * 00331 * 00332 * BS *BS_3_2_Minus_4_Or_1_Or_D(BS *set1,BS *set2,BS *set3, BS *set4, 00333 MEM_POOL *pool) 00334 * 00335 * Returns set1 |= (~set2 & set3) | set4 00336 * 00337 * 00338 * BS *BS_3_2_Minus_4_Or_5_Or_1_Or_D(BS *set1,BS *set2,BS *set3, 00339 BS *set4, BS *set5, MEM_POOL *pool) 00340 * 00341 * Returns set1 |= (~set2 & set3) | set4 | set5 00342 * 00343 * 00344 * BS *BS_2_1_Minus_3_Or_4_And_5_And_6_And_R( BS *result, BS *set1, BS *set2, BS *set3, 00345 * BS *set4, BS *set5, BS *set6, 00346 * MEM_POOL *pool) 00347 * 00348 * Returns result = (~set1 & set2 | set3) & set4 & set5 & set6 00349 * 00350 * 00351 * BS *BS_2_1_Minus_3_Or_4_And_R( BS *result, BS *set1, BS *set2, BS *set3, 00352 * BS *set4, 00353 * MEM_POOL *pool) 00354 * 00355 * Returns result = (~set1 & set2 | set3) & set4 00356 * 00357 * 00358 * BS *BS_1_Not_2_Or_3_Minus_4_And_R( BS *result, 00359 * BS *set1, BS *set2, BS *set3, BS *set4, 00360 * MEM_POOL *pool ) 00361 * 00362 * Returns result = ((~set1) | set2) & (~set3) & set4 00363 * 00364 * 00365 * BS *BS_2_3_Or_1_Or_D(BS *set1,BS *set2,BS *set3, MEM_POOL *pool) 00366 * 00367 * Returns set1 |= (set2 | set3) 00368 * 00369 * 00370 * BS *BS_1_2_Or_3_And_R(BS *result,BS *set1,BS *set2,BS *set3, MEM_POOL *pool) 00371 * 00372 * Returns result = (set1 | set2) & set3 00373 * 00374 * 00375 * BS *BS_2_3_And_1_Or_D(BS *set1,BS *set2,BS *set3, MEM_POOL *pool) 00376 * 00377 * Returns set1 = set1 | (set2 & set3) 00378 * 00379 * 00380 * BS *BS_3_Not_4_Or_2_And_1_Or_D(BS *set1,BS *set2,BS *set3,BS *set4, MEM_POOL *pool) 00381 * 00382 * Returns set1 = set1 | (set2 * (~set3 | set4)) 00383 * 00384 * 00385 * BS *BS_4_3_Minus_2_Not_Or_1_And_D(BS *set1,BS *set2,BS *set3,BS *set4, MEM_POOL *pool) 00386 * 00387 * Returns set1 = set1 * (~set2 | (set4 * ~set3)) 00388 * 00389 * 00390 * BS *BS_2_3_Minus_1_Or_D(BS *set1,BS *set2,BS *set3, MEM_POOL *pool) 00391 * 00392 * Returns set1 = set1 | (set2 * ~set3) 00393 * 00394 * 00395 * BS *BS_2_3_Minus_4_Minus_1_Or_D(BS *set1,BS *set2,BS *set3,BS *set4, MEM_POOL *pool) 00396 * 00397 * Returns set1 = set1 | (set2 * ~set3 * ~set4) 00398 * 00399 * 00400 * 00401 * Testing Sets 00402 * ============ 00403 * 00404 * 00405 * BOOL BS_ContainsP( BS *set1, BS *set2 ) 00406 * 00407 * Returns TRUE iff every element of 'set2' is in 'set1'. Else FALSE. 00408 * 00409 * 00410 * BOOL BS_EmptyP( BS *set ) 00411 * 00412 * Returns TRUE iff 'set' is empty. Else FALSE. 00413 * 00414 * 00415 * BOOL BS_EqualP( BS *set1, BS *set2 ) 00416 * 00417 * Returns TRUE iff 'set1' has exactly the same members as 'set2'. 00418 * Else FALSE. 00419 * 00420 * 00421 * BOOL BS_IntersectsP( BS *set1, BS *set2 ) 00422 * 00423 * Returns TRUE iff 'set1' and 'set2' have at least one member in 00424 * common. Else FALSE. 00425 * 00426 * 00427 * BOOL BS_MemberP( BS *set, BS_ELT x ) 00428 * 00429 * Returns TRUE iff 'x' is a member of 'set'. Else FALSE. 'X' 00430 * must be nonnegative or an error is caused. 00431 * 00432 * BOOL BS_Intersection_MemberP( BS *set1, BS *set2, BS_ELT x ) 00433 * 00434 * Returns TRUE iff 'x' is a member of the intersection of 'set1' and 00435 * 'set2'. 00436 * 00437 * 00438 * Looping Over Members 00439 * ==================== 00440 * 00441 * BS_ELT BS_Choose_Next( BS *set, BS_ELT elt ) 00442 * 00443 * Returns the next element of 'set' after elt. If there is no such 00444 * element, returns BS_CHOOSE_FAILURE. This is useful for looping 00445 * over the elements of a set. 00446 * 00447 * Here's an example of how this is used: 00448 * 00449 * BS_ELT elt; 00450 * for ( elt = BS_Choose( set ); 00451 * elt != BS_CHOOSE_FAILURE; 00452 * elt = BS_Choose_Next( set, elt ) ) 00453 * { 00454 * elt is an element of the set 00455 * } 00456 * 00457 * Looping over Members of an Intersection 00458 * ======================================= 00459 * 00460 * BS_ELT BS_Intersection_Choose_Next( BS *set1, BS *set2, BS_ELT x ) 00461 * 00462 * Returns the first member after 'x' of the intersection of 'set1' 00463 * and 'set2' or BS_CHOOSE_FAILURE if the intersection is empty. 00464 * 00465 * Printing Sets 00466 * ============= 00467 * 00468 * 00469 * void BS_Print( BS *set, FILE *f ) 00470 * 00471 * Prints 'set' on 'f'. The type FILE is as defined in stdio.h. 00472 */ 00473 00474 #ifndef defs_INCLUDED 00475 #include "defs.h" 00476 #endif /* defs_INCLUDED */ 00477 00478 typedef struct bs BS; 00479 typedef INT32 BS_ELT; 00480 00481 struct bv; 00482 00483 00484 /* Machine dependent definitions that will need to be changed for 64 00485 * bit implementation: 00486 */ 00487 00488 /* The basic word storage unit of a BS (MUST BE UNSIGNED) 00489 */ 00490 #if defined(_MIPS_ISA) && _MIPS_ISA >= 3 00491 typedef mUINT64 BS_WORD; 00492 #define LOG2_BITS_PER_BS_WORD 6 00493 #else 00494 typedef mUINT32 BS_WORD; 00495 #define LOG2_BITS_PER_BS_WORD 5 00496 #endif 00497 00498 typedef mUINT8 BS_BYTE; 00499 00500 #define BITS_PER_BS_WORD (sizeof(BS_WORD) * 8) 00501 #define BYTES_PER_BS_WORD (sizeof(BS_WORD)) 00502 00503 /* 00504 * bs_PBPW(x) Product of (x * Bits Per Word) 00505 * bs_QBPW(x) Quotient of ( x / Bits Per Word) 00506 * bs_RBPW(x) Remainder of ( x / Bits Per Word) 00507 * bs_PBPB(x) Product of (x * Bits Per Byte) 00508 * bs_QBPB(x) Quotient of (x / Bits Per Byte) 00509 * bs_RBPB(x) Remainder of ( x / Bits Per Byte) 00510 * bs_PBytesPW(x) Product of (x * Bytes Per Word) 00511 */ 00512 #define bs_PBPW(x) ((BS_ELT) ((x) << LOG2_BITS_PER_BS_WORD)) 00513 #define bs_QBPW(x) ((BS_ELT) ((x) >> LOG2_BITS_PER_BS_WORD)) 00514 #define bs_RBPW(x) ((BS_ELT) ((x) & ((1 << LOG2_BITS_PER_BS_WORD) - 1))) 00515 #define bs_PBPB(x) ((BS_ELT) ((x) << 3)) 00516 #define bs_QBPB(x) ((BS_ELT) ((x) >> 3)) 00517 #define bs_RBPB(x) ((BS_ELT) ((x) & 0x7)) 00518 #define bs_PBytesPW(x) ((BS_ELT) ((x) * BYTES_PER_BS_WORD)) 00519 00520 /* bs_ZEROS a word of zeros 00521 * bs_ONES a word of ones 00522 * bs_ONE just 1 00523 */ 00524 #define bs_ZEROS ((BS_WORD) 0) 00525 #define bs_ONES ((BS_WORD) ~0) 00526 #define bs_ONE ((BS_WORD) 1) 00527 00528 /* End of machine dependent part. 00529 */ 00530 00531 00532 /* Representation of a bit set is a pointer to a sequence of the 00533 * words. The first of these words gives the length of the set in 00534 * total number of words available to hold members (does not include 00535 * the first word which holds the length.) 00536 * 00537 * The sets are essentially BYTE addressed, with word addressing used 00538 * only to improve the effeciency of operations that must look at the 00539 * whole set. This has two advantages (on machines with effecient 00540 * byte addressing such as MIPS). Firstly, it is an endian 00541 * independent representation. Secondly it allows us to implement 00542 * very effecient Find_First_One and Population_Count operations at 00543 * the byte level as each only requires a table of 256 entries. 00544 * 00545 * x is an element of set if 00546 * 00547 * 1. x < BITS_PER_BS_WORD * BS_word_count(x), and 00548 * 2. BS_byte(set,x / 8) & (1 << x & 0x7) != bs_ZEROS 00549 */ 00550 00551 /* Basic access to BS's: 00552 * 00553 * BS_word_count(set) Number of words allocated to hold elements 00554 * of set 00555 * BS_word(set,i) i'th word of set 00556 * BS_byte(set,i) i'th byte of set 00557 */ 00558 #define BS_word_count(x) (*((BS_WORD *) x)) 00559 #define BS_word(x,i) (*(((BS_WORD *) x) + (i) + 1)) 00560 #define BS_byte(x,i) (*(((unsigned char *) x) + (i) + sizeof(BS_WORD))) 00561 00562 00563 /* Throw away a bit of address space to get a sane out of range 00564 * element. This already doesn't matter and in the 64 bit environment 00565 * it really won't. 00566 */ 00567 #define BS_MIN_ELT ((BS_ELT) 0) 00568 #define BS_MAX_ELT ((BS_ELT) UINT32_MAX) 00569 #define BS_CHOOSE_FAILURE ((BS_ELT) -1) 00570 00571 extern BS *BS_Create( BS_ELT size, MEM_POOL *pool ); 00572 extern size_t BS_Size_Alloc_Size( BS_ELT size ); 00573 extern size_t BS_Alloc_Size( BS *set ); 00574 extern BS *BS_ClearD( BS *set ); 00575 extern BS *BS_Create_Empty( BS_ELT size, MEM_POOL *pool ); 00576 extern BS *BS_ResizeD( BS* set, BS_ELT new_size, MEM_POOL *pool ); 00577 extern BS *BS_Range( BS_ELT low, BS_ELT high, MEM_POOL *pool ); 00578 extern BS *BS_RangeD( BS* set, BS_ELT low, BS_ELT high, MEM_POOL *pool ); 00579 extern BS *BS_Singleton( BS_ELT element, MEM_POOL *pool ); 00580 extern BS *BS_SingletonD( BS *set, BS_ELT element, MEM_POOL *pool ); 00581 extern BS *BS_Universe( BS_ELT size, MEM_POOL *pool ); 00582 extern BS *BS_UniverseD( BS *set, BS_ELT size, MEM_POOL *pool ); 00583 extern BS *BS_Copy( BS *set, MEM_POOL *pool ); 00584 extern BS *BS_CopyD( BS *set1, BS *set2, MEM_POOL *pool ); 00585 extern BS_ELT BS_Choose( const BS *bs ); 00586 extern BS_ELT BS_Intersection_Choose( BS *set1, BS *set2 ); 00587 extern BS_ELT BS_Choose_Range( BS *set, BS_ELT low, BS_ELT high ); 00588 extern BS *BS_Difference( BS *set1, BS *set2, MEM_POOL *pool ); 00589 extern BS *BS_DifferenceD( BS *set1, BS *set2 ); 00590 extern BS *BS_Difference1( BS *set, BS_ELT x, MEM_POOL *pool ); 00591 extern BS *BS_Difference1D( BS *set, BS_ELT x ); 00592 extern BS *BS_Intersection( BS *set1, BS *set2, MEM_POOL *pool ); 00593 extern BS *BS_IntersectionD( BS *set1, BS *set2 ); 00594 extern BS *BS_IntersectionR(BS* result, const BS *set1, const BS *set2); 00595 extern BS_ELT BS_Size( BS *set ); 00596 extern BS *BS_Union( BS *set1, BS *set2, MEM_POOL *pool ); 00597 extern BS *BS_UnionD( BS *set1, BS *set2, MEM_POOL *pool ); 00598 extern BS *BS_UnionR( BS *result, BS *set1, BS *set2, MEM_POOL *pool ); 00599 extern BS *BS_Union1( BS *set, BS_ELT x, MEM_POOL *pool ); 00600 extern BS* BS_UnionD_Intersection( BS* set1, BS* set2, BS* set3, 00601 MEM_POOL *pool ); 00602 extern BS *BS_Union1D( BS *set, BS_ELT x, MEM_POOL *pool ); 00603 00604 extern BS *BS_2_1_Minus_3_Or_R( BS *result, const BS *set1, const BS *set2, 00605 const BS *set3, MEM_POOL *pool ); 00606 extern BS *BS_3_2_Minus_1_Or_D( BS *set1, const BS *set2, 00607 const BS *set3, MEM_POOL *pool ); 00608 extern BS *BS_2_3_Or_1_Or_D( BS *set1, const BS *set2, const BS *set3, 00609 MEM_POOL *pool ); 00610 extern BS *BS_1_2_Or_3_And_R( BS *result, const BS *set1, const BS *set2, 00611 const BS *set3, MEM_POOL *pool ); 00612 extern BS *BS_2_3_And_1_Or_D( BS *set1, const BS *set2, 00613 const BS *set3, MEM_POOL *pool ); 00614 extern BS *BS_1_Not_2_Or_3_Minus_4_And_R( BS *result, const BS *set1, 00615 const BS *set2, const BS *set3, const BS *set4, 00616 MEM_POOL *pool ); 00617 00618 extern BS *BS_2_1_Minus_3_Or_4_And_5_And_6_And_R( BS *result, const BS *set1, 00619 const BS *set2, const BS *set3, const BS *set4, 00620 const BS *set5, const BS *set6, MEM_POOL *pool); 00621 extern BS *BS_2_1_Minus_3_Or_4_And_R( BS *result, const BS *set1, 00622 const BS *set2, const BS *set3, const BS *set4, 00623 MEM_POOL *pool); 00624 extern BS *BS_3_2_Minus_4_Or_1_Or_D( BS *set1, const BS *set2, 00625 const BS *set3, const BS *set4, MEM_POOL *pool); 00626 extern BS *BS_3_2_Minus_4_Or_5_Or_1_Or_D( BS *set1, const BS *set2, 00627 const BS *set3, const BS *set4, const BS *set5, 00628 MEM_POOL *pool ); 00629 extern BS *BS_3_Not_4_Or_2_And_1_Or_D( BS *result, const BS *set1, 00630 const BS *set2, const BS *set3, MEM_POOL *pool); 00631 extern BS *BS_4_3_Minus_2_Not_Or_1_And_D(BS *result, const BS *set1, 00632 const BS *set2, const BS *set3, MEM_POOL *pool); 00633 extern BS *BS_2_3_Minus_1_Or_D(BS *result, const BS *set1, 00634 const BS *set2, MEM_POOL *pool); 00635 extern BS *BS_2_3_Minus_4_Minus_1_Or_D(BS *result, const BS *set1, 00636 const BS *set2, const BS *set3, MEM_POOL *pool); 00637 extern BOOL BS_ContainsP( BS *set1, BS *set2 ); 00638 extern BOOL BS_EmptyP( BS *set ); 00639 extern BOOL BS_EqualP( BS *set1, BS *set2 ); 00640 extern BOOL BS_IntersectsP( BS *set1, BS *set2 ); 00641 extern BOOL BS_MemberP( BS *set, BS_ELT x ); 00642 extern BOOL BS_Intersection_MemberP( BS *set1, BS *set2, BS_ELT x ); 00643 extern BS_ELT BS_Choose_Next( const BS *set, BS_ELT elt); 00644 extern BS_ELT BS_Intersection_Choose_Next(BS *set1, BS *set2, BS_ELT elt); 00645 00646 /* FBS -- fixed-size bitset implementation. 00647 Fixed size bitsets are faster because no implicit reallocation 00648 is required. For debugging, a slower implementation that 00649 verifies the range of x is in bitset.c. 00650 */ 00651 extern BOOL FBS_MemberP_Validate(BS *set, BS_ELT x); 00652 extern void FBS_Union1D_Validate(BS *set, BS_ELT x); 00653 00654 #ifdef Is_True_On 00655 #define FBS_MemberP(set, x) FBS_MemberP_Validate(set, x) 00656 #define FBS_Union1D(set, x) FBS_Union1D_Validate(set, x) 00657 #else 00658 #define FBS_MemberP(set, x) (BS_byte(set,bs_QBPB(x)) & (bs_ONE << bs_RBPB(x))) 00659 #define FBS_Union1D(set, x) (BS_byte(set,bs_QBPB(x)) |= bs_ONE << bs_RBPB(x)) 00660 #endif 00661 00662 extern void BS_Print( BS *set, FILE *f ); 00663 #pragma mips_frequency_hint NEVER BS_Print 00664 00665 #ifdef __cplusplus 00666 } 00667 #endif 00668 #endif /* bitset_INCLUDED */ 00669
1.5.6