BitSet.h

00001 //
00002 // $Id: BitSet.h,v 1.26 2007/03/08 19:59:21 will_mason Exp $
00003 //
00004 // vi: set ft=objc:
00005 
00006 /*
00007  * ObjectiveLib - a library of containers and algorithms for Objective-C
00008  *
00009  * Copyright (c) 2004-2007
00010  * Will Mason
00011  *
00012  * Portions:
00013  *
00014  * Copyright (c) 1994
00015  * Hewlett-Packard Company
00016  *
00017  * Copyright (c) 1996,1997
00018  * Silicon Graphics Computer Systems, Inc.
00019  *
00020  * Copyright (c) 1997
00021  * Moscow Center for SPARC Technology
00022  *
00023  * Copyright (c) 1999 
00024  * Boris Fomitchev
00025  *
00026  * This library is free software; you can redistribute it and/or
00027  * modify it under the terms of the GNU Lesser General Public
00028  * License as published by the Free Software Foundation; either
00029  * version 2.1 of the License, or (at your option) any later version.
00030  *
00031  * This library is distributed in the hope that it will be useful,
00032  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00033  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00034  * Lesser General Public License for more details.
00035  *
00036  * You should have received a copy of the GNU Lesser General Public
00037  * License along with this library; if not, write to the Free Software
00038  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00039  *
00040  * You may contact the author at will_mason@users.sourceforge.net.
00041  */
00042 
00043 #if !defined(BITSET_OL_GUARD)
00044 #define BITSET_OL_GUARD
00045 
00046 #include <ObjectiveLib/ObjectBase.h>
00047 #if defined(OL_HAVE_INTTYPES_H)
00048 #include <inttypes.h>
00049 #else
00050 #include <stdint.h>
00051 #endif
00052 
00067 @interface OLBitSet :
00068 #if defined(OL_NO_OPENSTEP)
00069     Object <OLStreamable>
00070 #else
00071     NSObject <OLStreamable, NSCopying, NSCoding>
00072 #endif
00073 {
00074 @protected
00078     uint32_t*       words;
00079 
00083     unsigned        numberOfBits;
00084 
00088     unsigned        numberOfWords;
00089 }
00090 
00101 + (id) bitSetWithBitSet: (OLBitSet*)bitSet;
00102 
00113 + (id) bitSetWithSetSize: (unsigned)bits;
00114 
00132 + (id) bitSetWithString: (const char*)str position: (unsigned)pos count: (unsigned)count;
00133 
00145 + (id) bitSetWithValue: (uint32_t)val;
00146 
00150 /* @{ */
00157 - (id) initWithBitSet: (OLBitSet*)bitSet;
00158 
00159 #if !defined(OL_NO_OPENSTEP)
00160 
00169 - (id) initWithCoder: (NSCoder*)decoder;
00170 #endif
00171 
00172 - (id) initWithObjectInStream: (OLObjectInStream*)stream;
00173 
00181 - (id) initWithSetSize: (unsigned)bits;
00182 
00196 - (id) initWithString: (const char*)str position: (unsigned)pos count: (unsigned)count;
00197 
00207 - (id) initWithValue: (uint32_t)val;
00208 
00212 #if defined(OL_NO_OPENSTEP)
00213 - (id) free;
00214 #else
00215 - (void) dealloc;
00216 #endif
00217 /* @} */
00218 
00224 - (BOOL) any;
00225 
00236 - (OLBitSet*) bitSetFlipped;
00237 
00251 - (OLBitSet*) bitSetShiftedLeft: (unsigned)count;
00252 
00266 - (OLBitSet*) bitSetShiftedRight: (unsigned)count;
00267 
00268 #if defined(OL_NO_OPENSTEP)
00269 
00274 - (id) copy;
00275 #else
00276 
00282 - (id) copyWithZone: (NSZone*)zone;
00283 #endif
00284 
00291 - (unsigned) count;
00292 
00293 #if !defined(OL_NO_OPENSTEP)
00294 
00300 - (void) encodeWithCoder: (NSCoder*)encoder;
00301 #endif
00302 
00307 - (void) flip;
00308 
00319 - (void) flip: (unsigned)pos;
00320 
00328 - (BOOL) isEqual: (id)object;
00329 
00339 - (void) logicalAnd: (OLBitSet*)right;
00340 
00350 - (void) logicalOr: (OLBitSet*)right;
00351 
00361 - (void) logicalXor: (OLBitSet*)right;
00362 
00368 - (BOOL) none;
00369 
00373 - (void) reset;
00374 
00384 - (void) reset: (unsigned)pos;
00385 
00389 - (void) set;
00390 
00400 - (void) set: (unsigned)pos;
00401 
00408 - (void) shiftLeft: (unsigned)count;
00409 
00416 - (void) shiftRight: (unsigned)count;
00417 
00423 - (unsigned) size;
00424 
00434 - (BOOL) test: (unsigned)pos;
00435 
00448 - (char*) toString;
00449 
00450 - (void) writeSelfToStream: (OLObjectOutStream*)stream;
00451 
00452 @end
00453 
00454 #endif

ObjectiveLibGenerated Sun Apr 22 15:17:58 2007, © 2004-2007 Will Mason
SourceForge.net Logo