src/share/vm/libadt/vectset.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 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  *
  23  */
  24 





  25 #ifndef _VECTOR_SET_
  26 #define _VECTOR_SET_
  27 // Vector Sets - An Abstract Data Type
  28 //INTERFACE
  29 
  30 // These sets can grow or shrink, based on the initial size and the largest
  31 // element currently in them.  Slow and bulky for sparse sets, these sets
  32 // are super for dense sets.  They are fast and compact when dense.
  33 
  34 // TIME:
  35 // O(1) - Insert, Delete, Member, Sort
  36 // O(max_element) - Create, Clear, Size, Copy, Union, Intersect, Difference,
  37 //                  Equal, ChooseMember, Forall
  38 
  39 // SPACE: (max_element)/(8*sizeof(int))
  40 
  41 
  42 //------------------------------VectorSet--------------------------------------
  43 class VectorSet : public Set {
  44 friend class VectorSetI;        // Friendly iterator class


 157 
 158 class VSetI_ : public SetI_ {
 159   friend class VectorSet;
 160   friend class VectorSetI;
 161   const VectorSet *s;
 162   uint i, j;
 163   uint32 mask;
 164   VSetI_(const VectorSet *vset);
 165   uint next(void);
 166   int test(void) { return i < s->size; }
 167 };
 168 
 169 class VectorSetI : public SetI {
 170 public:
 171   VectorSetI( const VectorSet *s ) : SetI(s) { }
 172   void operator ++(void) { elem = ((VSetI_*)impl)->next(); }
 173   int test(void) { return ((VSetI_*)impl)->test(); }
 174 };
 175 
 176 #endif // _VECTOR_SET_


   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_LIBADT_VECTSET_HPP
  26 #define SHARE_VM_LIBADT_VECTSET_HPP
  27 
  28 #include "libadt/set.hpp"
  29 
  30 #ifndef _VECTOR_SET_
  31 #define _VECTOR_SET_
  32 // Vector Sets - An Abstract Data Type
  33 //INTERFACE
  34 
  35 // These sets can grow or shrink, based on the initial size and the largest
  36 // element currently in them.  Slow and bulky for sparse sets, these sets
  37 // are super for dense sets.  They are fast and compact when dense.
  38 
  39 // TIME:
  40 // O(1) - Insert, Delete, Member, Sort
  41 // O(max_element) - Create, Clear, Size, Copy, Union, Intersect, Difference,
  42 //                  Equal, ChooseMember, Forall
  43 
  44 // SPACE: (max_element)/(8*sizeof(int))
  45 
  46 
  47 //------------------------------VectorSet--------------------------------------
  48 class VectorSet : public Set {
  49 friend class VectorSetI;        // Friendly iterator class


 162 
 163 class VSetI_ : public SetI_ {
 164   friend class VectorSet;
 165   friend class VectorSetI;
 166   const VectorSet *s;
 167   uint i, j;
 168   uint32 mask;
 169   VSetI_(const VectorSet *vset);
 170   uint next(void);
 171   int test(void) { return i < s->size; }
 172 };
 173 
 174 class VectorSetI : public SetI {
 175 public:
 176   VectorSetI( const VectorSet *s ) : SetI(s) { }
 177   void operator ++(void) { elem = ((VSetI_*)impl)->next(); }
 178   int test(void) { return ((VSetI_*)impl)->test(); }
 179 };
 180 
 181 #endif // _VECTOR_SET_
 182 
 183 #endif // SHARE_VM_LIBADT_VECTSET_HPP