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 _SET_
26 #define _SET_
27 // Sets - An Abstract Data Type
28
29 // Should not manually include these in AVM framework. %%%%% - Ungar
30 // #ifndef _PORT_
31 // #include "port.hpp"
32 // #endif // _PORT_
33 //INTERFACE
34
35 class SparseSet;
36 class VectorSet;
37 class ListSet;
38 class CoSet;
39
40 class ostream;
41 class SetI_;
42
43 // These sets can grow or shrink, based on the initial size and the largest
44 // element currently in them. Basically, they allow a bunch of bits to be
45 // grouped together, tested, set & cleared, intersected, etc. The basic
46 // Set class is an abstract class, and cannot be constructed. Instead,
47 // one of VectorSet, SparseSet, or ListSet is created. Each variation has
48 // different asymptotic running times for different operations, and different
49 // constants of proportionality as well.
50 // {n = number of elements, N = largest element}
51
52 // VectorSet SparseSet ListSet
231 protected:
232 friend class SetI;
233 virtual ~SetI_();
234 virtual uint next(void)=0;
235 virtual int test(void)=0;
236 };
237
238 class SetI {
239 protected:
240 SetI_ *impl;
241 public:
242 uint elem; // The publically accessible element
243
244 SetI( const Set *s ) { impl = s->iterate(elem); }
245 ~SetI() { delete impl; }
246 void reset( const Set *s ) { delete impl; impl = s->iterate(elem); }
247 void operator ++(void) { elem = impl->next(); }
248 int test(void) { return impl->test(); }
249 };
250
251 #endif // _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_SET_HPP
26 #define SHARE_VM_LIBADT_SET_HPP
27
28 #include "libadt/port.hpp"
29 #include "memory/allocation.hpp"
30
31 // Sets - An Abstract Data Type
32
33 //INTERFACE
34
35 class SparseSet;
36 class VectorSet;
37 class ListSet;
38 class CoSet;
39
40 class ostream;
41 class SetI_;
42
43 // These sets can grow or shrink, based on the initial size and the largest
44 // element currently in them. Basically, they allow a bunch of bits to be
45 // grouped together, tested, set & cleared, intersected, etc. The basic
46 // Set class is an abstract class, and cannot be constructed. Instead,
47 // one of VectorSet, SparseSet, or ListSet is created. Each variation has
48 // different asymptotic running times for different operations, and different
49 // constants of proportionality as well.
50 // {n = number of elements, N = largest element}
51
52 // VectorSet SparseSet ListSet
231 protected:
232 friend class SetI;
233 virtual ~SetI_();
234 virtual uint next(void)=0;
235 virtual int test(void)=0;
236 };
237
238 class SetI {
239 protected:
240 SetI_ *impl;
241 public:
242 uint elem; // The publically accessible element
243
244 SetI( const Set *s ) { impl = s->iterate(elem); }
245 ~SetI() { delete impl; }
246 void reset( const Set *s ) { delete impl; impl = s->iterate(elem); }
247 void operator ++(void) { elem = impl->next(); }
248 int test(void) { return impl->test(); }
249 };
250
251 #endif // SHARE_VM_LIBADT_SET_HPP
|