1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bitset.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFXBITSET_HXX
31 #define _SFXBITSET_HXX
33 #include <tools/solar.h>
40 void CopyFrom( const BitSet
& rSet
);
45 BitSet
operator<<( USHORT nOffset
) const;
46 BitSet
operator>>( USHORT nOffset
) const;
47 static USHORT
CountBits( ULONG nBits
);
48 BOOL
operator!() const;
50 BitSet( const BitSet
& rOrig
);
51 BitSet( USHORT
* pArray
, USHORT nSize
);
53 BitSet( const Range
& rRange
);
55 BitSet
& operator=( const BitSet
& rOrig
);
56 BitSet
& operator=( USHORT nBit
);
57 BitSet
operator|( const BitSet
& rSet
) const;
58 BitSet
operator|( USHORT nBit
) const;
59 BitSet
& operator|=( const BitSet
& rSet
);
60 BitSet
& operator|=( USHORT nBit
);
61 BitSet
operator-( const BitSet
& rSet
) const;
62 BitSet
operator-( USHORT nId
) const;
63 BitSet
& operator-=( const BitSet
& rSet
);
64 BitSet
& operator-=( USHORT nBit
);
65 BitSet
operator&( const BitSet
& rSet
) const;
66 BitSet
& operator&=( const BitSet
& rSet
);
67 BitSet
operator^( const BitSet
& rSet
) const;
68 BitSet
operator^( USHORT nBit
) const;
69 BitSet
& operator^=( const BitSet
& rSet
);
70 BitSet
& operator^=( USHORT nBit
);
71 BOOL
IsRealSubSet( const BitSet
& rSet
) const;
72 BOOL
IsSubSet( const BitSet
& rSet
) const;
73 BOOL
IsRealSuperSet( const BitSet
& rSet
) const;
74 BOOL
Contains( USHORT nBit
) const;
75 BOOL
IsSuperSet( const BitSet
& rSet
) const;
76 BOOL
operator==( const BitSet
& rSet
) const;
77 BOOL
operator==( USHORT nBit
) const;
78 BOOL
operator!=( const BitSet
& rSet
) const;
79 BOOL
operator!=( USHORT nBit
) const;
82 //--------------------------------------------------------------------
84 // returns TRUE if the set is empty
88 inline BOOL
BitSet::operator!() const
92 //--------------------------------------------------------------------
94 // returns the number of bits in the bitset
96 inline USHORT
BitSet::Count() const
100 //--------------------------------------------------------------------
102 // creates the union of two bitset
104 inline BitSet
BitSet::operator|( const BitSet
& rSet
) const
106 return BitSet(*this) |= rSet
;
108 //--------------------------------------------------------------------
110 // creates the union of a bitset with a single bit
112 inline BitSet
BitSet::operator|( USHORT nBit
) const
114 return BitSet(*this) |= nBit
;
116 //--------------------------------------------------------------------
118 // creates the asymetric difference
120 inline BitSet
BitSet::operator-( const BitSet
& ) const
124 //--------------------------------------------------------------------
126 // creates the asymetric difference with a single bit
129 inline BitSet
BitSet::operator-( USHORT
) const
133 //--------------------------------------------------------------------
135 // removes the bits contained in rSet
137 inline BitSet
& BitSet::operator-=( const BitSet
& )
141 //--------------------------------------------------------------------
144 // creates the intersection with another bitset
146 inline BitSet
BitSet::operator&( const BitSet
& ) const
150 //--------------------------------------------------------------------
152 // intersects with another bitset
154 inline BitSet
& BitSet::operator&=( const BitSet
& )
158 //--------------------------------------------------------------------
160 // creates the symetric difference with another bitset
162 inline BitSet
BitSet::operator^( const BitSet
& ) const
166 //--------------------------------------------------------------------
168 // creates the symetric difference with a single bit
170 inline BitSet
BitSet::operator^( USHORT
) const
174 //--------------------------------------------------------------------
176 // builds the symetric difference with another bitset
178 inline BitSet
& BitSet::operator^=( const BitSet
& )
182 //--------------------------------------------------------------------
184 // builds the symetric difference with a single bit
186 inline BitSet
& BitSet::operator^=( USHORT
)
192 //--------------------------------------------------------------------
194 // determines if the other bitset is a real superset
196 inline BOOL
BitSet::IsRealSubSet( const BitSet
& ) const
200 //--------------------------------------------------------------------
202 // detsermines if the other bitset is a superset or equal
204 inline BOOL
BitSet::IsSubSet( const BitSet
& ) const
208 //--------------------------------------------------------------------
210 // determines if the other bitset is a real subset
212 inline BOOL
BitSet::IsRealSuperSet( const BitSet
& ) const
217 //--------------------------------------------------------------------
219 // determines if the other bitset is a subset or equal
221 inline BOOL
BitSet::IsSuperSet( const BitSet
& ) const
225 //--------------------------------------------------------------------
227 // determines if the bit is the only one in the bitset
229 inline BOOL
BitSet::operator==( USHORT
) const
233 //--------------------------------------------------------------------
235 // determines if the bitsets aren't equal
237 inline BOOL
BitSet::operator!=( const BitSet
& rSet
) const
239 return !( *this == rSet
);
241 //--------------------------------------------------------------------
243 // determines if the bitset doesn't contain only this bit
245 inline BOOL
BitSet::operator!=( USHORT nBit
) const
247 return !( *this == nBit
);
249 //--------------------------------------------------------------------
251 class IndexBitSet
: BitSet
254 USHORT
GetFreeIndex();
255 void ReleaseIndex(USHORT i
){*this-=i
;}