Index: trunk/psLib/src/collections/psBitSet.c
===================================================================
--- trunk/psLib/src/collections/psBitSet.c	(revision 542)
+++ trunk/psLib/src/collections/psBitSet.c	(revision 578)
@@ -1,14 +1,15 @@
-/** @file  psBitMask.c
+/** @file  psBitSet.c
  *
- *  @brief Creates an array of bits of arbitrary length.
+ *  @brief Creates an array of bytes of arbitrary length for storing individual bits.
  *
- *  Bit masks are useful for turning options on and off. This module provides functions to create an array of 
- *  bits of arbitrary length and manipulate them with basic binary operations. A print function is also 
- *  provided to display the entire set of bits in binary form.
+ *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
+ *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary 
+ *  operations. A print function is also provided to display the entire set of bits in binary format as a
+ *  string.
  *
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-28 17:47:24 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,11 +23,43 @@
 #include <ctype.h>
 
-#include "psBitMask.h"
+#include "psBitSet.h"
 #include "psMemory.h"
+#include "psError.h"
+
+/******************************************************************************/
+/*  DEFINE STATEMENTS                                                         */
+/******************************************************************************/
+
+// None
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  GLOBAL VARIABLES                                                         */
+/*****************************************************************************/
+
+// None
+
+/*****************************************************************************/
+/*  FILE STATIC VARIABLES                                                    */
+/*****************************************************************************/
+
+// None
 
 /*****************************************************************************/
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
-static char* getByte(int bit, const psBitMask *restrict inMask)
+
+/** Private function to return a byte.
+ *
+ *  Finds the byte containing the bit within the byte array.
+ *
+ *  @return  char*: Pointer to byte in which bit is contained.
+ */
+static char* getByte(int bit, const psBitSet *restrict inMask)
 {
     int index = 0;
@@ -38,4 +71,11 @@
 }
 
+/** Private function to create a mask.
+ *
+ *  Creates an eight bit mask with the given bit set. All other bits in the byte are zero. The input bit uses
+ *  zero-based indexing, and is the cumulitive index within the array, not the localized byte's bit position.
+ *
+ *  @return  char*: Pointer to byte in which bit is contained.
+ */
 static char mask(int bit)
 {
@@ -49,7 +89,7 @@
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
 /*****************************************************************************/
-psBitMask* psBitMaskAlloc(int n)
+psBitSet* psBitSetAlloc(int n)
 {
-    psBitMask *newObj = psAlloc(sizeof(psBitMask));
+    psBitSet *newObj = psAlloc(sizeof(psBitSet));
     newObj->n = n;
     newObj->bits = psAlloc(sizeof(char)*n);
@@ -59,21 +99,21 @@
 }
 
-void psBitMaskFree(psBitMask *restrict inMask)
+void psBitSetFree(psBitSet *restrict inBitSet)
 {
-    psFree(inMask->bits);
-    psFree(inMask);
+    psFree(inBitSet->bits);
+    psFree(inBitSet);
 }
 
-psBitMask* psBitMaskSet(psBitMask *inMask, int bit)
+psBitSet* psBitSetSet(psBitSet *inBitSet, int bit)
 {
-    char* byte = getByte(bit, inMask);
+    char* byte = getByte(bit, inBitSet);
     *byte |= mask(bit);
 
-    return inMask;
+    return inBitSet;
 }
 
-int psBitMaskTest(const psBitMask *inMask, int bit)
+int psBitSetTest(const psBitSet *inBitSet, int bit)
 {
-    char* byte = getByte(bit, inMask);
+    char* byte = getByte(bit, inBitSet);
     if((*byte&mask(bit)) == 0) {
         return 0;
@@ -83,6 +123,6 @@
 }
 
-psBitMask* psBitMaskOp(psBitMask *outMask, const psBitMask *restrict inMask1, char *operator,
-                       const psBitMask *restrict inMask2)
+psBitSet* psBitSetOp(psBitSet *outBitSet, const psBitSet *restrict inBitSet1, char *operator,
+                     const psBitSet *restrict inBitSet2)
 {
     int i = 0;
@@ -93,34 +133,33 @@
     char *inBits2 = NULL;
 
-    if(outMask == NULL) {
-        printf("Null output psBitMask\n");
-        return outMask;
+    if(outBitSet == NULL) {
+        psError(__func__, " : Line %d - Null psBitSet for outBitSet argument\n", __LINE__);
+        return outBitSet;
     }
 
-    if(inMask1 == NULL) {
-        printf("Null input psBitMask1\n");
-        return outMask;
+    if(inBitSet1 == NULL) {
+        psError(__func__, " : Line %d - Null psBitSet for inBitSet1 argument\n", __LINE__);
+        return outBitSet;
     }
 
     if(operator == NULL) {
-        printf("Null input operator\n");
-        return outMask;
-
+        psError(__func__, " : Line %d - Null input operator\n", __LINE__);
+        return outBitSet;
     }
 
-    if(inMask2 == NULL) {
-        printf("Null input psBitMask2\n");
-        return outMask;
+    if(inBitSet2 == NULL) {
+        psError(__func__, " : Line %d - Null psBitSet for inBitSet2 argument\n", __LINE__);
+        return outBitSet;
     }
 
-    if(inMask1->n != inMask2->n || outMask->n != inMask1->n) {
-        printf("Mask sizes not the same\n");
-        return outMask;
+    if(inBitSet1->n != inBitSet2->n || outBitSet->n != inBitSet1->n) {
+        psError(__func__, " : Line %d - psBitSet sizes not the same\n", __LINE__);
+        return outBitSet;
     }
 
-    n = outMask->n;
-    outBits = outMask->bits;
-    inBits1 = inMask1->bits;
-    inBits2 = inMask2->bits;
+    n = outBitSet->n;
+    outBits = outBitSet->bits;
+    inBits1 = inBitSet1->bits;
+    inBits2 = inBitSet2->bits;
 
     tempChar = toupper(*operator);
@@ -142,17 +181,17 @@
         break;
     default:
-        printf("Invalid psBitMask option %s\n", operator);
+        psError(__func__, " : Line %d - Invalid psBitMask binary operation: %s\n", __LINE__);
     }
 
-    return outMask;
+    return outBitSet;
 }
 
-char *psBitMaskToString(const psBitMask *restrict inMask)
+char *psBitSetToString(const psBitSet *restrict inBitSet)
 {
     int i = 0;
-    int numBits = inMask->n*8;
-    char* outString = (char*)malloc(numBits);
+    int numBits = inBitSet->n*8;
+    char* outString = psAlloc(numBits);
     for(i=0; i<numBits; i++) {
-        outString[numBits-i-1] = (psBitMaskTest(inMask, i))?'1':'0';
+        outString[numBits-i-1] = (psBitSetTest(inBitSet, i))?'1':'0';
     }
 
