1 | /*
|
---|
2 | * Copyright 1999-2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Log: BitSet.hpp,v $
|
---|
19 | * Revision 1.5 2004/09/08 13:56:21 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.4 2004/01/29 11:48:46 cargilld
|
---|
23 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
24 | *
|
---|
25 | * Revision 1.3 2003/05/15 19:04:35 knoaman
|
---|
26 | * Partial implementation of the configurable memory manager.
|
---|
27 | *
|
---|
28 | * Revision 1.2 2002/11/04 15:22:03 tng
|
---|
29 | * C++ Namespace Support.
|
---|
30 | *
|
---|
31 | * Revision 1.1.1.1 2002/02/01 22:22:10 peiyongz
|
---|
32 | * sane_include
|
---|
33 | *
|
---|
34 | * Revision 1.4 2000/03/02 19:54:38 roddey
|
---|
35 | * This checkin includes many changes done while waiting for the
|
---|
36 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
37 | * available elsewhere.
|
---|
38 | *
|
---|
39 | * Revision 1.3 2000/02/24 20:05:24 abagchi
|
---|
40 | * Swat for removing Log from API docs
|
---|
41 | *
|
---|
42 | * Revision 1.2 2000/02/06 07:48:01 rahulj
|
---|
43 | * Year 2K copyright swat.
|
---|
44 | *
|
---|
45 | * Revision 1.1.1.1 1999/11/09 01:04:11 twl
|
---|
46 | * Initial checkin
|
---|
47 | *
|
---|
48 | * Revision 1.2 1999/11/08 20:45:05 rahul
|
---|
49 | * Swat for adding in Product name and CVS comment log variable.
|
---|
50 | *
|
---|
51 | */
|
---|
52 |
|
---|
53 | #if !defined(BITSET_HPP)
|
---|
54 | #define BITSET_HPP
|
---|
55 |
|
---|
56 | #include <xercesc/util/XMemory.hpp>
|
---|
57 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
58 |
|
---|
59 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
60 |
|
---|
61 | class XMLUTIL_EXPORT BitSet : public XMemory
|
---|
62 | {
|
---|
63 | public:
|
---|
64 | // -----------------------------------------------------------------------
|
---|
65 | // Constructors and Destructor
|
---|
66 | // -----------------------------------------------------------------------
|
---|
67 | BitSet( const unsigned int size
|
---|
68 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
69 | BitSet(const BitSet& toCopy);
|
---|
70 | ~BitSet();
|
---|
71 |
|
---|
72 |
|
---|
73 | // -----------------------------------------------------------------------
|
---|
74 | // Equality methods
|
---|
75 | // -----------------------------------------------------------------------
|
---|
76 | bool equals(const BitSet& other) const;
|
---|
77 |
|
---|
78 |
|
---|
79 | // -----------------------------------------------------------------------
|
---|
80 | // Getter methods
|
---|
81 | // -----------------------------------------------------------------------
|
---|
82 | bool allAreCleared() const;
|
---|
83 | bool allAreSet() const;
|
---|
84 | unsigned int size() const;
|
---|
85 | bool get(const unsigned int index) const;
|
---|
86 |
|
---|
87 |
|
---|
88 | // -----------------------------------------------------------------------
|
---|
89 | // Setter methods
|
---|
90 | // -----------------------------------------------------------------------
|
---|
91 | void clear(const unsigned int index);
|
---|
92 | void clearAll();
|
---|
93 | void set(const unsigned int index);
|
---|
94 |
|
---|
95 |
|
---|
96 | // -----------------------------------------------------------------------
|
---|
97 | // Bitwise logical operations
|
---|
98 | // -----------------------------------------------------------------------
|
---|
99 | void andWith(const BitSet& other);
|
---|
100 | void orWith(const BitSet& other);
|
---|
101 | void xorWith(const BitSet& other);
|
---|
102 |
|
---|
103 |
|
---|
104 | // -----------------------------------------------------------------------
|
---|
105 | // Miscellaneous
|
---|
106 | // -----------------------------------------------------------------------
|
---|
107 | unsigned int hash(const unsigned int hashModulus) const;
|
---|
108 |
|
---|
109 |
|
---|
110 | private :
|
---|
111 | // -----------------------------------------------------------------------
|
---|
112 | // Unimplemented constructors
|
---|
113 | // -----------------------------------------------------------------------
|
---|
114 | BitSet();
|
---|
115 | BitSet& operator=(const BitSet&);
|
---|
116 | // -----------------------------------------------------------------------
|
---|
117 | // Private methods
|
---|
118 | // -----------------------------------------------------------------------
|
---|
119 | void ensureCapacity(const unsigned int bits);
|
---|
120 |
|
---|
121 |
|
---|
122 | // -----------------------------------------------------------------------
|
---|
123 | // Data members
|
---|
124 | //
|
---|
125 | // fBits
|
---|
126 | // The array of unsigned longs used to store the bits.
|
---|
127 | //
|
---|
128 | // fUnitLen
|
---|
129 | // The length of the storage array, in storage units not bits.
|
---|
130 | // -----------------------------------------------------------------------
|
---|
131 | MemoryManager* fMemoryManager;
|
---|
132 | unsigned long* fBits;
|
---|
133 | unsigned int fUnitLen;
|
---|
134 | };
|
---|
135 |
|
---|
136 | XERCES_CPP_NAMESPACE_END
|
---|
137 |
|
---|
138 | #endif
|
---|