< prev index next >

src/hotspot/share/libadt/set.hpp

Print this page


   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  *


 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


   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  *


 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 &s) : ResourceObj(s) {};
 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


< prev index next >