/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "libadt/vectset.hpp"
#include "memory/allocation.inline.hpp"
// Vector Sets - An Abstract Data Type
// %%%%% includes not needed with AVM framework - Ungar
// #include "port.hpp"
//IMPLEMENTATION
// #include "vectset.hpp"
// BitsInByte is a lookup table which tells the number of bits that
// are in the looked-up number. It is very useful in VectorSet_Size.
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};
//------------------------------VectorSet--------------------------------------
// Create a new, empty Set.
data[0] = 0; // No elements
data[1] = 0;
}
//------------------------------Construct--------------------------------------
{
}
//------------------------------operator=--------------------------------------
{
if( &set == this ) return *this;
// The cast is a virtual function that checks that "set" is a VectorSet.
return *this;
}
//------------------------------slamin-----------------------------------------
// Initialize one set with another. No regard is made to the existing Set.
{
}
//------------------------------grow-------------------------------------------
// Expand the existing set to a bigger size
{
while( x < newsize ) x <<= 1;
size = x;
}
//------------------------------operator<<=------------------------------------
// Insert a member into an existing Set.
{
return *this;
}
//------------------------------operator>>=------------------------------------
// Delete a member from an existing Set.
{
return *this; // Then it's clear & return clear
return *this;
}
//------------------------------operator&=-------------------------------------
// Intersect one set into another.
{
// NOTE: The intersection is never any larger than the smallest set.
return *this; // Return set
}
//------------------------------operator&=-------------------------------------
{
// The cast is a virtual function that checks that "set" is a VectorSet.
return (*this) &= *(set.asVectorSet());
}
//------------------------------operator|=-------------------------------------
// Union one set into another.
{
// This many words must be unioned
// Extend result by larger set
}
return *this; // Return result set
}
//------------------------------operator|=-------------------------------------
{
// The cast is a virtual function that checks that "set" is a VectorSet.
return (*this) |= *(set.asVectorSet());
}
//------------------------------operator-=-------------------------------------
// Difference one set from another.
{
// This many words must be unioned
return *this; // Return new set
}
//------------------------------operator-=-------------------------------------
{
// The cast is a virtual function that checks that "set" is a VectorSet.
return (*this) -= *(set.asVectorSet());
}
//------------------------------compare----------------------------------------
// Compute 2 booleans: bits in A not B, bits in B not A.
// Return X0 -- A is not a subset of B
// X1 -- A is a subset of B
// 0X -- B is not a subset of A
// 1X -- B is a subset of A
{
// This many words must be unioned
// Get bits for both sets
uint i; // Exit value of loop
for( i=0; i<cnt; i++ ) { // For data in BOTH sets
AnotB |= (A & ~B); // Compute bits in A not B
BnotA |= (B & ~A); // Compute bits in B not A
}
// Get bits from bigger set
for( ; i<s.size; i++ ) // For data in larger set
} else {
for( ; i<size; i++ ) // For data in larger set
}
// Set & return boolean flags
}
//------------------------------operator==-------------------------------------
// Test for set equality
{
}
//------------------------------operator==-------------------------------------
{
// The cast is a virtual function that checks that "set" is a VectorSet.
return (*this) == *(set.asVectorSet());
}
//------------------------------disjoint---------------------------------------
// Check for sets being disjoint.
{
// The cast is a virtual function that checks that "set" is a VectorSet.
// NOTE: The intersection is never any larger than the smallest set.
return 0; // Then not disjoint
return 1; // Else disjoint
}
//------------------------------operator<--------------------------------------
// Test for strict subset
{
}
//------------------------------operator<--------------------------------------
{
// The cast is a virtual function that checks that "set" is a VectorSet.
return (*this) < *(set.asVectorSet());
}
//------------------------------operator<=-------------------------------------
// Test for subset
{
}
//------------------------------operator<=-------------------------------------
{
// The cast is a virtual function that checks that "set" is a VectorSet.
return (*this) <= *(set.asVectorSet());
}
//------------------------------operator[]-------------------------------------
{
return 0; // Then it's clear
}
//------------------------------getelem----------------------------------------
// Get any element from the set.
{
uint i; // Exit value of loop
for( i=0; i<size; i++ )
if( data[i] )
break;
int j; // Exit value of loop
return (i<<5)+j;
}
//------------------------------Clear------------------------------------------
// Clear a set
{
}
}
//------------------------------Size-------------------------------------------
// Return number of elements in a Set
{
return sum;
}
//------------------------------Sort-------------------------------------------
// Sort the elements for the next forall statement
{
}
//------------------------------hash-------------------------------------------
{
return (int)_xor;
}
//------------------------------iterate----------------------------------------
// Used by Set::print().
public:
};
}
//=============================================================================
//------------------------------next-------------------------------------------
// Find and return the next element of a vector set, or return garbage and
// make "VectorSetI::test()" fail.
{
j++; // Next element in word
do { // Do While still have words
while( mask ) { // While have bits in word
return (i<<5)+j; // Return the bit address
}
j++; // Skip to next bit
}
j = 0; // No more bits in word; setup for next word
mask = 1;
} while( i<s->size );
return max_juint; // No element, iterated them all
}