< prev index next >

src/hotspot/share/libadt/set.hpp

Print this page
rev 52793 : imported patch fix
   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  95 //      void foo(VectorSet vs1, VectorSet vs2) { vs1 |= vs2; }
  96 // "foo" must be called with a VectorSet.  The vector set union operation
  97 // is called directly.
  98 //      void foo(Set vs1, Set vs2) { vs1 |= vs2; }
  99 // "foo" may be called with *any* kind of sets; suppose it is called with
 100 // VectorSets.  Two virtual function calls are used to figure out the that vs1
 101 // and vs2 are VectorSets.  In addition, if vs2 is not a VectorSet then a
 102 // temporary VectorSet copy of vs2 will be made before the union proceeds.
 103 //
 104 // VectorSets have a small constant.  Time and space are proportional to the
 105 //   largest element.  Fine for dense sets and largest element < 10,000.
 106 // SparseSets have a medium constant.  Time is proportional to the number of
 107 //   elements, space is proportional to the largest element.
 108 //   Fine (but big) with the largest element < 100,000.
 109 // ListSets have a big constant.  Time *and space* are proportional to the
 110 //   number of elements.  They work well for a few elements of *any* size
 111 //   (i.e. sets of pointers)!
 112 
 113 //------------------------------Set--------------------------------------------
 114 class Set : public ResourceObj {
 115  public:
 116 
 117   // Creates a new, empty set.
 118   // DO NOT CONSTRUCT A Set.  THIS IS AN ABSTRACT CLASS, FOR INHERITENCE ONLY
 119   Set(Arena *arena) : _set_arena(arena) {};
 120 
 121   // Creates a new set from an existing set
 122   // DO NOT CONSTRUCT A Set.  THIS IS AN ABSTRACT CLASS, FOR INHERITENCE ONLY
 123   Set(const Set &) {};
 124 

 125   // Set assignment; deep-copy guts
 126   virtual Set &operator =(const Set &s)=0;
 127   virtual Set &clone(void) const=0;
 128 
 129   // Virtual destructor
 130   virtual ~Set() {};
 131 
 132   // Add member to set
 133   virtual Set &operator <<=(uint elem)=0;
 134   // virtual Set  operator << (uint elem);
 135 
 136   // Delete member from set
 137   virtual Set &operator >>=(uint elem)=0;
 138   // virtual Set  operator >> (uint elem);
 139 
 140   // Membership test.  Result is Zero (absent)/ Non-Zero (present)
 141   virtual int operator [](uint elem) const=0;
 142 
 143   // Intersect sets
 144   virtual Set &operator &=(const Set &s)=0;


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  95 //      void foo(VectorSet vs1, VectorSet vs2) { vs1 |= vs2; }
  96 // "foo" must be called with a VectorSet.  The vector set union operation
  97 // is called directly.
  98 //      void foo(Set vs1, Set vs2) { vs1 |= vs2; }
  99 // "foo" may be called with *any* kind of sets; suppose it is called with
 100 // VectorSets.  Two virtual function calls are used to figure out the that vs1
 101 // and vs2 are VectorSets.  In addition, if vs2 is not a VectorSet then a
 102 // temporary VectorSet copy of vs2 will be made before the union proceeds.
 103 //
 104 // VectorSets have a small constant.  Time and space are proportional to the
 105 //   largest element.  Fine for dense sets and largest element < 10,000.
 106 // SparseSets have a medium constant.  Time is proportional to the number of
 107 //   elements, space is proportional to the largest element.
 108 //   Fine (but big) with the largest element < 100,000.
 109 // ListSets have a big constant.  Time *and space* are proportional to the
 110 //   number of elements.  They work well for a few elements of *any* size
 111 //   (i.e. sets of pointers)!
 112 
 113 //------------------------------Set--------------------------------------------
 114 class Set : public ResourceObj {
 115  protected:
 116 
 117   // Creates a new, empty set.

 118   Set(Arena *arena) : _set_arena(arena) {};
 119 
 120   // Creates a new set from an existing set
 121   Set(const Set & s) : ResourceObj(s) {};

 122 
 123  public:
 124   // Set assignment; deep-copy guts
 125   virtual Set &operator =(const Set &s)=0;
 126   virtual Set &clone(void) const=0;
 127 
 128   // Virtual destructor
 129   virtual ~Set() {};
 130 
 131   // Add member to set
 132   virtual Set &operator <<=(uint elem)=0;
 133   // virtual Set  operator << (uint elem);
 134 
 135   // Delete member from set
 136   virtual Set &operator >>=(uint elem)=0;
 137   // virtual Set  operator >> (uint elem);
 138 
 139   // Membership test.  Result is Zero (absent)/ Non-Zero (present)
 140   virtual int operator [](uint elem) const=0;
 141 
 142   // Intersect sets
 143   virtual Set &operator &=(const Set &s)=0;


< prev index next >