2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: BitVector.h /main/4 1996/08/21 15:49:59 drk $ */
26 #define _BitVector_h 1
35 //#include <StyleSheet/cde_next.h>
36 #include "dti_cc/CC_Slist.h"
44 posRecord(unsigned int x = 0, unsigned int y = 0) :
45 pathTermPos(x), bitPos(y) {};
48 unsigned int operator ==(const posRecord&);
51 unsigned int pathTermPos;
55 typedef CC_TValSlist<posRecord> positionArrayT;
56 typedef CC_TValSlistIterator<posRecord> positionArrayIteratorT;
58 ///////////////////////////////////////////////////////
59 // A storage/manipulation efficient bit vector class
60 ///////////////////////////////////////////////////////
63 unsigned int *f_array;
66 positionArrayT *f_positionArray;
69 BitVector(int bits, unsigned int initValue);
73 // bits range: 0 .. bits-1
74 // the 0th bit is LSB, the (bits-1)th bit is MSB
76 void setAllBitsTo(unsigned int);
77 void setTo(BitVector&);
79 void recordPositions(unsigned int pathTermPos, unsigned int BitPos);
80 positionArrayT* positionArray() { return f_positionArray; };
82 void setBitTo(int i, unsigned int);
83 unsigned int getBit(int i);
85 BitVector& operator &=(BitVector&);
86 BitVector& operator ^=(BitVector&);
87 BitVector& operator |=(BitVector&);
89 // Note: the MSB is set to 1 after each shiftRightOneBit() call.
90 BitVector& shiftRightOneBit();
91 BitVector& shiftLeftOneBit();
93 friend ostream& operator<<(ostream&, BitVector&);