/*
* 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.
*
*/
#ifndef SHARE_VM_LIBADT_VECTSET_HPP
#define SHARE_VM_LIBADT_VECTSET_HPP
// Vector Sets - An Abstract Data Type
//INTERFACE
// These sets can grow or shrink, based on the initial size and the largest
// element currently in them. Slow and bulky for sparse sets, these sets
// are super for dense sets. They are fast and compact when dense.
// TIME:
// O(1) - Insert, Delete, Member, Sort
// O(max_element) - Create, Clear, Size, Copy, Union, Intersect, Difference,
// Equal, ChooseMember, Forall
// SPACE: (max_element)/(8*sizeof(int))
//------------------------------VectorSet--------------------------------------
friend class VectorSetI; // Friendly iterator class
protected:
public:
{ if( &s != this ) { slamin(s); } return *this; }
~VectorSet() {}
int operator ==(const VectorSet &s) const; // True if sets are equal
int operator ==(const Set &s) const; // True if sets are equal
int operator < (const VectorSet &s) const; // True if strict subset
int operator < (const Set &s) const; // True if strict subset
int operator <=(const VectorSet &s) const; // True if subset relation holds.
int operator <=(const Set &s) const; // True if subset relation holds.
void Clear(void); // Clear a set
void Sort(void); // Sort before iterating
int hash() const; // Hash function
}
/* Removed for MCC BUG
operator const VectorSet* (void) const { return this; } */
// Expose internals for speed-critical fast iterators
// Fast inlined "test and set". Replaces the idiom:
// if( visited[idx] ) return;
// visited <<= idx;
// With:
// if( visited.test_set(idx) ) return;
//
return datum; // Return bit
}
(*this) <<= elem; // Insert into set
return 0; // Return 0!
}
// Fast inlined test
}
// Fast inlined set
} else {
}
}
private:
};
//------------------------------Iteration--------------------------------------
// Loop thru all elements of the set, setting "elem" to the element numbers
// in random order. Inserted or deleted elements during this operation may
// or may not be iterated over; untouched elements will be affected once.
// Usage: for( VectorSetI i(s); i.test(); i++ ) { body = i.elem; }
friend class VectorSet;
const VectorSet *s;
uint i, j;
public:
s(vset),
i((uint)-1L),
j((uint)-1L),
}
};
#endif // SHARE_VM_LIBADT_VECTSET_HPP