[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: BitSet.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(BITSET_HPP) |
---|
| 23 | #define BITSET_HPP |
---|
| 24 | |
---|
| 25 | #include <xercesc/util/XMemory.hpp> |
---|
| 26 | #include <xercesc/util/PlatformUtils.hpp> |
---|
| 27 | |
---|
| 28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 29 | |
---|
| 30 | class XMLUTIL_EXPORT BitSet : public XMemory |
---|
| 31 | { |
---|
| 32 | public: |
---|
| 33 | // ----------------------------------------------------------------------- |
---|
| 34 | // Constructors and Destructor |
---|
| 35 | // ----------------------------------------------------------------------- |
---|
| 36 | BitSet( const unsigned int size |
---|
| 37 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 38 | BitSet(const BitSet& toCopy); |
---|
| 39 | ~BitSet(); |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | // ----------------------------------------------------------------------- |
---|
| 43 | // Equality methods |
---|
| 44 | // ----------------------------------------------------------------------- |
---|
| 45 | bool equals(const BitSet& other) const; |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | // ----------------------------------------------------------------------- |
---|
| 49 | // Getter methods |
---|
| 50 | // ----------------------------------------------------------------------- |
---|
| 51 | bool allAreCleared() const; |
---|
| 52 | bool allAreSet() const; |
---|
| 53 | unsigned int size() const; |
---|
| 54 | bool get(const unsigned int index) const; |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | // ----------------------------------------------------------------------- |
---|
| 58 | // Setter methods |
---|
| 59 | // ----------------------------------------------------------------------- |
---|
| 60 | void clear(const unsigned int index); |
---|
| 61 | void clearAll(); |
---|
| 62 | void set(const unsigned int index); |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | // ----------------------------------------------------------------------- |
---|
| 66 | // Bitwise logical operations |
---|
| 67 | // ----------------------------------------------------------------------- |
---|
| 68 | void andWith(const BitSet& other); |
---|
| 69 | void orWith(const BitSet& other); |
---|
| 70 | void xorWith(const BitSet& other); |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | // ----------------------------------------------------------------------- |
---|
| 74 | // Miscellaneous |
---|
| 75 | // ----------------------------------------------------------------------- |
---|
| 76 | unsigned int hash(const unsigned int hashModulus) const; |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | private : |
---|
| 80 | // ----------------------------------------------------------------------- |
---|
| 81 | // Unimplemented constructors |
---|
| 82 | // ----------------------------------------------------------------------- |
---|
| 83 | BitSet(); |
---|
| 84 | BitSet& operator=(const BitSet&); |
---|
| 85 | // ----------------------------------------------------------------------- |
---|
| 86 | // Private methods |
---|
| 87 | // ----------------------------------------------------------------------- |
---|
| 88 | void ensureCapacity(const unsigned int bits); |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | // ----------------------------------------------------------------------- |
---|
| 92 | // Data members |
---|
| 93 | // |
---|
| 94 | // fBits |
---|
| 95 | // The array of unsigned longs used to store the bits. |
---|
| 96 | // |
---|
| 97 | // fUnitLen |
---|
| 98 | // The length of the storage array, in storage units not bits. |
---|
| 99 | // ----------------------------------------------------------------------- |
---|
| 100 | MemoryManager* fMemoryManager; |
---|
| 101 | unsigned long* fBits; |
---|
| 102 | unsigned int fUnitLen; |
---|
| 103 | }; |
---|
| 104 | |
---|
| 105 | XERCES_CPP_NAMESPACE_END |
---|
| 106 | |
---|
| 107 | #endif |
---|