< prev index next >

src/hotspot/share/libadt/vectset.cpp

Print this page
rev 50962 : [mq]: 8207011

*** 99,110 **** //------------------------------operator<<=------------------------------------ // Insert a member into an existing Set. Set &VectorSet::operator <<= (uint elem) { ! register uint word = elem >> 5; // Get the longword offset ! register uint32_t mask = 1L << (elem & 31); // Get bit mask if( word >= size ) // Need to grow set? grow(elem+1); // Then grow it data[word] |= mask; // Set new bit return *this; --- 99,110 ---- //------------------------------operator<<=------------------------------------ // Insert a member into an existing Set. Set &VectorSet::operator <<= (uint elem) { ! uint word = elem >> 5; // Get the longword offset ! uint32_t mask = 1L << (elem & 31); // Get bit mask if( word >= size ) // Need to grow set? grow(elem+1); // Then grow it data[word] |= mask; // Set new bit return *this;
*** 112,137 **** //------------------------------operator>>=------------------------------------ // Delete a member from an existing Set. Set &VectorSet::operator >>= (uint elem) { ! register uint word = elem >> 5; // Get the longword offset if( word >= size ) // Beyond the last? return *this; // Then it's clear & return clear ! register uint32_t mask = 1L << (elem & 31); // Get bit mask data[word] &= ~mask; // Clear bit return *this; } //------------------------------operator&=------------------------------------- // Intersect one set into another. VectorSet &VectorSet::operator &= (const VectorSet &s) { // NOTE: The intersection is never any larger than the smallest set. if( s.size < size ) size = s.size; // Get smaller size ! register uint32_t *u1 = data; // Pointer to the destination data ! register uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<size; i++) // For data in set *u1++ &= *u2++; // Copy and AND longwords return *this; // Return set } --- 112,137 ---- //------------------------------operator>>=------------------------------------ // Delete a member from an existing Set. Set &VectorSet::operator >>= (uint elem) { ! uint word = elem >> 5; // Get the longword offset if( word >= size ) // Beyond the last? return *this; // Then it's clear & return clear ! uint32_t mask = 1L << (elem & 31); // Get bit mask data[word] &= ~mask; // Clear bit return *this; } //------------------------------operator&=------------------------------------- // Intersect one set into another. VectorSet &VectorSet::operator &= (const VectorSet &s) { // NOTE: The intersection is never any larger than the smallest set. if( s.size < size ) size = s.size; // Get smaller size ! uint32_t *u1 = data; // Pointer to the destination data ! uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<size; i++) // For data in set *u1++ &= *u2++; // Copy and AND longwords return *this; // Return set }
*** 145,157 **** //------------------------------operator|=------------------------------------- // Union one set into another. VectorSet &VectorSet::operator |= (const VectorSet &s) { // This many words must be unioned ! register uint cnt = ((size<s.size)?size:s.size); ! register uint32_t *u1 = data; // Pointer to the destination data ! register uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<cnt; i++) // Copy and OR the two sets *u1++ |= *u2++; if( size < s.size ) { // Is set 2 larger than set 1? // Extend result by larger set grow(s.size*sizeof(uint32_t)*8); --- 145,157 ---- //------------------------------operator|=------------------------------------- // Union one set into another. VectorSet &VectorSet::operator |= (const VectorSet &s) { // This many words must be unioned ! uint cnt = ((size<s.size)?size:s.size); ! uint32_t *u1 = data; // Pointer to the destination data ! uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<cnt; i++) // Copy and OR the two sets *u1++ |= *u2++; if( size < s.size ) { // Is set 2 larger than set 1? // Extend result by larger set grow(s.size*sizeof(uint32_t)*8);
*** 170,182 **** //------------------------------operator-=------------------------------------- // Difference one set from another. VectorSet &VectorSet::operator -= (const VectorSet &s) { // This many words must be unioned ! register uint cnt = ((size<s.size)?size:s.size); ! register uint32_t *u1 = data; // Pointer to the destination data ! register uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<cnt; i++ ) // For data in set *u1++ &= ~(*u2++); // A <-- A & ~B with longwords return *this; // Return new set } --- 170,182 ---- //------------------------------operator-=------------------------------------- // Difference one set from another. VectorSet &VectorSet::operator -= (const VectorSet &s) { // This many words must be unioned ! uint cnt = ((size<s.size)?size:s.size); ! uint32_t *u1 = data; // Pointer to the destination data ! uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<cnt; i++ ) // For data in set *u1++ &= ~(*u2++); // A <-- A & ~B with longwords return *this; // Return new set }
*** 193,213 **** // X1 -- A is a subset of B // 0X -- B is not a subset of A // 1X -- B is a subset of A int VectorSet::compare (const VectorSet &s) const { ! register uint32_t *u1 = data; // Pointer to the destination data ! register uint32_t *u2 = s.data; // Pointer to the source data ! register uint32_t AnotB = 0, BnotA = 0; // This many words must be unioned ! register uint cnt = ((size<s.size)?size:s.size); // Get bits for both sets uint i; // Exit value of loop for( i=0; i<cnt; i++ ) { // For data in BOTH sets ! register uint32_t A = *u1++; // Data from one guy ! register uint32_t B = *u2++; // Data from other guy AnotB |= (A & ~B); // Compute bits in A not B BnotA |= (B & ~A); // Compute bits in B not A } // Get bits from bigger set --- 193,213 ---- // X1 -- A is a subset of B // 0X -- B is not a subset of A // 1X -- B is a subset of A int VectorSet::compare (const VectorSet &s) const { ! uint32_t *u1 = data; // Pointer to the destination data ! uint32_t *u2 = s.data; // Pointer to the source data ! uint32_t AnotB = 0, BnotA = 0; // This many words must be unioned ! uint cnt = ((size<s.size)?size:s.size); // Get bits for both sets uint i; // Exit value of loop for( i=0; i<cnt; i++ ) { // For data in BOTH sets ! uint32_t A = *u1++; // Data from one guy ! uint32_t B = *u2++; // Data from other guy AnotB |= (A & ~B); // Compute bits in A not B BnotA |= (B & ~A); // Compute bits in B not A } // Get bits from bigger set
*** 243,255 **** { // The cast is a virtual function that checks that "set" is a VectorSet. const VectorSet &s = *(set.asVectorSet()); // NOTE: The intersection is never any larger than the smallest set. ! register uint small_size = ((size<s.size)?size:s.size); ! register uint32_t *u1 = data; // Pointer to the destination data ! register uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<small_size; i++) // For data in set if( *u1++ & *u2++ ) // If any elements in common return 0; // Then not disjoint return 1; // Else disjoint } --- 243,255 ---- { // The cast is a virtual function that checks that "set" is a VectorSet. const VectorSet &s = *(set.asVectorSet()); // NOTE: The intersection is never any larger than the smallest set. ! uint small_size = ((size<s.size)?size:s.size); ! uint32_t *u1 = data; // Pointer to the destination data ! uint32_t *u2 = s.data; // Pointer to the source data for( uint i=0; i<small_size; i++) // For data in set if( *u1++ & *u2++ ) // If any elements in common return 0; // Then not disjoint return 1; // Else disjoint }
*** 284,297 **** //------------------------------operator[]------------------------------------- // Test for membership. A Zero/Non-Zero value is returned! int VectorSet::operator[](uint elem) const { ! register uint word = elem >> 5; // Get the longword offset if( word >= size ) // Beyond the last? return 0; // Then it's clear ! register uint32_t mask = 1L << (elem & 31); // Get bit mask return ((data[word] & mask))!=0; // Return the sense of the bit } //------------------------------getelem---------------------------------------- // Get any element from the set. --- 284,297 ---- //------------------------------operator[]------------------------------------- // Test for membership. A Zero/Non-Zero value is returned! int VectorSet::operator[](uint elem) const { ! uint word = elem >> 5; // Get the longword offset if( word >= size ) // Beyond the last? return 0; // Then it's clear ! uint32_t mask = 1L << (elem & 31); // Get bit mask return ((data[word] & mask))!=0; // Return the sense of the bit } //------------------------------getelem---------------------------------------- // Get any element from the set.
< prev index next >