Index: /trunk/psLib/src/collections/psArray.c
===================================================================
--- /trunk/psLib/src/collections/psArray.c	(revision 577)
+++ /trunk/psLib/src/collections/psArray.c	(revision 578)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-22 21:15:01 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -48,10 +48,12 @@
 /*****************************************************************************/
 
-static void* p_psArrayAlloc(psType *arrType, psElemType elemType, int nalloc, int elemSize)
+static void* p_psArrayAlloc(psArray *restrict psArr, psElemType elemType, int nalloc, int elemSize)
 {
     void *arr = NULL;
 
-    arrType->dimen = PS_DIMEN_VECTOR;
-    arrType->type = elemType;
+    psArr->type.dimen = PS_DIMEN_VECTOR;
+    psArr->type.type = elemType;
+    psArr->nalloc = nalloc;
+    psArr->n = 0;
 
     if(nalloc != 0) {
@@ -62,209 +64,158 @@
 }
 
-static psVoidPtrArray *p_psVoidPtrArrayRealloc(psVoidPtrArray *restrict psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
+static void* p_psArrayRealloc(psArray *restrict psArr, void *arr, int nalloc, int elemSize)
+{
+    // For decrease in psArray size
+    if(nalloc < psArr->n) {
         psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(void*));   // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(void*));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
+    }
+
+    psArr->nalloc = nalloc;
+
+    return psRealloc(arr, nalloc*elemSize);
+}
+
+/*****************************************************************************/
+/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+/*****************************************************************************/
+psArray* psIntArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.intArr = (int*)p_psArrayAlloc(psArr, PS_TYPE_INT, nalloc, sizeof(int));
+    return psArr;
+}
+
+psArray *psIntArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psIntArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.intArr = p_psArrayRealloc(psArr, psArr->arr.intArr, nalloc, sizeof(int));
+    }
+
+    return psArr;
+}
+
+void psIntArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+
+    psFree(psArr->arr.intArr);
+    psFree(psArr);
+}
+
+psArray* psFloatArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.fltArr = (float*)p_psArrayAlloc(psArr, PS_TYPE_FLOAT, nalloc, sizeof(float));
+    return psArr;
+}
+
+psArray *psFloatArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psFloatArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.fltArr = p_psArrayRealloc(psArr, psArr->arr.fltArr, nalloc, sizeof(float));
+    }
+
+    return psArr;
+}
+
+void psFloatArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    psFree(psArr->arr.fltArr);
+    psFree(psArr);
+}
+
+psArray* psDoubleArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.dblArr = (double*)p_psArrayAlloc(psArr, PS_TYPE_DOUBLE, nalloc, sizeof(double));
+    return psArr;
+}
+
+psArray *psDoubleArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psDoubleArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.dblArr = p_psArrayRealloc(psArr, psArr->arr.dblArr, nalloc, sizeof(double));
+    }
+
+    return psArr;
+}
+
+void psDoubleArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    psFree(psArr->arr.dblArr);
+    psFree(psArr);
+}
+
+psArray* psComplexArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.cFltArr = (complex float*)p_psArrayAlloc(psArr, PS_TYPE_COMPLEX, nalloc, sizeof(complex float));
+    return psArr;
+}
+
+psArray *psComplexArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psComplexArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.cFltArr = p_psArrayRealloc(psArr, psArr->arr.cFltArr, nalloc, sizeof(complex float));
+    }
+
+    return psArr;
+}
+
+void psComplexArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    psFree(psArr->arr.cFltArr);
+    psFree(psArr);
+}
+
+psArray* psVoidPtrArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.ptrArr = p_psArrayAlloc(psArr, PS_TYPE_OTHER, nalloc, sizeof(void *));
+    return psArr;
+}
+
+psArray *psVoidPtrArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    int i = 0;
+
+    for (i = nalloc; i < psArr->n; i++) {               // For reduction in array size
+        psMemDecrRefCounter(psArr->arr.ptrArr[i]);
+    }
+
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
         psArr = psVoidPtrArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-static void p_psVoidPtrArrayFree(psVoidPtrArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-/*****************************************************************************/
-/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
-/*****************************************************************************/
-
-psIntArray* psIntArrayAlloc(int nalloc)
-{
-    psIntArray *psArr = NULL;
-    psArr = (psIntArray*)psAlloc(sizeof(psIntArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (int*)p_psArrayAlloc(&psArr->type, PS_TYPE_INT, nalloc, sizeof(int));
-
-    return psArr;
-}
-
-psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(int));     // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(int));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
-        psArr = psIntArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psIntArrayFree(psIntArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psFloatArray* psFloatArrayAlloc(int nalloc)
-{
-    psFloatArray *psArr = NULL;
-    psArr = (psFloatArray*)psAlloc(sizeof(psFloatArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (float*)p_psArrayAlloc(&psArr->type, PS_TYPE_FLOAT, nalloc, sizeof(float));
-
-    return psArr;
-}
-
-psFloatArray *psFloatArrayRealloc(psFloatArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(float));   // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(float));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
-        psArr = psFloatArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psFloatArrayFree(psFloatArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psDoubleArray* psDoubleArrayAlloc(int nalloc)
-{
-    psDoubleArray *psArr = NULL;
-    psArr = (psDoubleArray*)psAlloc(sizeof(psDoubleArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (double*)p_psArrayAlloc(&psArr->type, PS_TYPE_DOUBLE, nalloc, sizeof(double));
-
-    return psArr;
-}
-
-psDoubleArray *psDoubleArrayRealloc(psDoubleArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(double));  // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(double));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
-        psArr = psDoubleArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psDoubleArrayFree(psDoubleArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psComplexArray* psComplexArrayAlloc(int nalloc)
-{
-    psComplexArray *psArr = NULL;
-    psArr = (psComplexArray*)psAlloc(sizeof(psComplexArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (complex float*)p_psArrayAlloc(&psArr->type, PS_TYPE_COMPLEX, nalloc, sizeof(complex float));
-
-    return psArr;
-}
-
-psComplexArray *psComplexArrayRealloc(psComplexArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                                 // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(complex float));   // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(complex float));
-    } else if(psArr == NULL) {                                              // For creating new psArray with realloc
-        psArr = psComplexArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psComplexArrayFree(psComplexArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psVoidPtrArray* psVoidPtrArrayAlloc(int nalloc)
-{
-    psVoidPtrArray *psArr = NULL;
-    psArr = (psVoidPtrArray*)psAlloc(sizeof(psVoidPtrArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (void*)p_psArrayAlloc(&psArr->type, PS_TYPE_OTHER, nalloc, sizeof(void*));
-
-    return psArr;
-}
-
-psVoidPtrArray *psVoidPtrArrayRealloc(psVoidPtrArray *restrict psArr, int nalloc, void (*elemFree)(void *))
-{
-    int i = 0;
-
-    if(psArr == NULL) {
-        return psArr;
-    }
-
-    for (i = nalloc; i < psArr->n; i++) {
-        if(elemFree == NULL) {
-            psMemDecrRefCounter(psArr->arr[i]);
-        } else {
-            elemFree(psMemDecrRefCounter(psArr->arr[i]));
-        }
-    }
-
-    return p_psVoidPtrArrayRealloc(psArr, nalloc);
-}
-
-void psVoidPtrArrayFree(psVoidPtrArray *restrict psArr, void (*elemFree)(void *))
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.ptrArr = p_psArrayRealloc(psArr, psArr->arr.ptrArr, nalloc, sizeof(void *));
+    }
+
+    return psArr;
+}
+
+void psVoidPtrArrayFree(psArray *restrict psArr, void (*elemFree)(void *))
 {
     int i = 0;
@@ -276,10 +227,13 @@
     for(i = 0; i < psArr->nalloc; i++) {
         if(elemFree == NULL) {
-            psMemDecrRefCounter(psArr->arr[i]);
+            psMemDecrRefCounter(psArr->arr.ptrArr[i]);
         } else {
-            elemFree(psMemDecrRefCounter(psArr->arr[i]));
+            elemFree(psMemDecrRefCounter(psArr->arr.ptrArr[i]));
         }
     }
-    p_psVoidPtrArrayFree(psArr);
-}
-
+
+    // Free pointer array
+    psFree(psArr->arr.ptrArr);
+    psFree(psArr);
+}
+
Index: /trunk/psLib/src/collections/psArray.h
===================================================================
--- /trunk/psLib/src/collections/psArray.h	(revision 577)
+++ /trunk/psLib/src/collections/psArray.h	(revision 578)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-23 21:33:59 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -75,75 +75,24 @@
 psType;
 
-/** An array of integers.
- *
- * Struct for maintaining an array of integer numbers.
+/** An array of generic primitive types.
+ *
+ * Struct for maintaining an array of frequently used primitive types.
  *
  */
 typedef struct
 {
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Total number of elements available.
-    int n;          ///< Number of elements in use.
-    int *arr;       ///< Array data.
+    psType type;                ///< Type of data.
+    int nalloc;                 ///< Total number of elements available.
+    int n;                      ///< Number of elements in use.
+
+    union {
+        int *intArr;            ///< Integer array.
+        float *fltArr;          ///< Single precision floating point array.
+        double *dblArr;         ///< Double precision floating point array.
+        complex float *cFltArr; ///< Single precision floating pont complex array.
+        void **ptrArr;          ///< Void pointer array.
+    }arr;                       ///< Union with array data.
 }
-psIntArray;
-
-/** An array of floats.
- *
- * Struct for maintaining an array of single precision floating point numbers.
- *
- */
-typedef struct
-{
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Total number of elements available.
-    int n;          ///< Number of elements in use.
-    float *arr;     ///< Array data.
-}
-psFloatArray;
-
-/** An array of doubles.
- *
- * Struct for maintaining an array of double precision floating point numbers.
- *
- */
-typedef struct
-{
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Total number of elements available.
-    int n;          ///< Number of elements in use.
-    double *arr;    ///< Array data.
-}
-psDoubleArray;
-
-/** An array of complex numbers.
- *
- * Struct for maintaining an array of single precision floating point complex numbers.
- *
- */
-typedef struct
-{
-    psType type;        ///< Type of data.
-    int nalloc;         ///< Total number of elements available.
-    int n;              ///< Number of elements in use
-    complex float *arr; ///< Array data.
-}
-psComplexArray;
-
-/** An array of void pointers.
- *
- * Struct for maintaining an array of void pointers. This struct needs a deallocation function that accepts
- * deallocation of the array elements.
- *
- */
-typedef struct
-{
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Number of total elements.
-    int n;          ///< Number of elements in use.
-    void **arr;     ///< Aray data.
-}
-psVoidPtrArray;
-
+psArray;
 
 /*****************************************************************************/
@@ -155,6 +104,8 @@
  * Uses psLib memory allocation functions to create an array of integers as defined by the psIntArray struct. 
  *
- */
-psIntArray *psIntArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psIntArrayAlloc(
     int nalloc  ///< Total number of elements to make available.
 );
@@ -165,7 +116,9 @@
  * struct. 
  *
- */
-psIntArray *psIntArrayRealloc(
-    psIntArray *myArray,    ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psIntArrayRealloc(
+    psArray *myArray,       ///< Array to reallocate.
     int nalloc              ///< Total number of elements to make available.
 );
@@ -177,7 +130,9 @@
  * struct. 
  *
+ * @return void
+ *
  */
 void psIntArrayFree(
-    psIntArray *restrict psArr  ///< Array to free.
+    psArray *restrict psArr  ///< Array to free.
 );
 
@@ -186,6 +141,8 @@
  * Uses psLib memory allocation functions to create an array of floats as defined by the psFloatArray struct. 
  *
- */
-psFloatArray *psFloatArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psFloatArrayAlloc(
     int nalloc  ///< Total number of elements to make available.
 );
@@ -196,7 +153,9 @@
  * struct. 
  *
- */
-psFloatArray *psFloatArrayRealloc(
-    psFloatArray *psArr,    ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psFloatArrayRealloc(
+    psArray *psArr,         ///< Array to reallocate.
     int nalloc              ///< Total number of elements to make available.
 );
@@ -207,7 +166,9 @@
  * struct. 
  *
+ * @return void
+ *
  */
 void psFloatArrayFree(
-    psFloatArray *restrict myArray  ///< Array to free.
+    psArray *restrict myArray  ///< Array to free.
 );
 
@@ -217,6 +178,8 @@
  * struct. 
  *
- */
-psDoubleArray *psDoubleArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psDoubleArrayAlloc(
     int nalloc  ///< Total number of elements to make available.
 );
@@ -227,7 +190,9 @@
  * struct. 
  *
- */
-psDoubleArray *psDoubleArrayRealloc(
-    psDoubleArray *psArr,   ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psDoubleArrayRealloc(
+    psArray *psArr,         ///< Array to reallocate.
     int nalloc              ///< Total number of elements to make available.
 );
@@ -238,7 +203,9 @@
  * struct. 
  *
+ * @return void
+ *
  */
 void psDoubleArrayFree(
-    psDoubleArray *restrict psArr  ///< Array to free.
+    psArray *restrict psArr  ///< Array to free.
 );
 
@@ -248,6 +215,8 @@
  * numbers as defined by the psComplexArray struct.
  *
- */
-psComplexArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available.
 ;
 
@@ -257,7 +226,9 @@
  * numbers as defined by the psComplexArray struct.
  *
- */
-psComplexArray *psComplexArrayRealloc(
-    psComplexArray *myArray,    ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psComplexArrayRealloc(
+    psArray *psArr,            ///< Array to reallocate.
     int nalloc                  ///< Total number of elements to make available.
 );
@@ -268,7 +239,9 @@
  * numbers as defined by the psComplexArray struct.
  *
+ * @return void
+ *
  */
 void psComplexArrayFree(
-    psComplexArray *restrict psArr  ///< Array to free.
+    psArray *restrict psArr  ///< Array to free.
 );
 
@@ -278,6 +251,8 @@
  * struct.
  *
- */
-psVoidPtrArray *psVoidPtrArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psVoidPtrArrayAlloc(
     int nalloc  ///< Number of elements to use.
 );
@@ -286,11 +261,13 @@
  *
  * Uses psLib memory allocation functions to reallocate an array of void pointers as defined by the 
- * psVoidPtrArray struct.
- *
- */
-psVoidPtrArray *psVoidPtrArrayRealloc(
-    psVoidPtrArray *restrict psArr, ///< Array to reallocate.
-    int nalloc,                     ///< Number of elements.
-    void (*elemFree)(void *)        ///< Callback function responsible for removing array data.
+ * psVoidPtrArray struct. If the array size is increased or decreased, this function does not allocate or 
+ * deallocate the contents of individual array elements. The user must do this after calling this function.
+ *
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psVoidPtrArrayRealloc(
+    psArray *restrict psArr,        ///< Void pointer array to destroy.
+    int nalloc                      ///< Number of elements.
 );
 
@@ -298,10 +275,15 @@
  *
  * Uses psLib memory allocation functions to deallocate an array of void pointers as defined by the 
- * psVoidPtrArray struct.
+ * psVoidPtrArray struct. This function does not free the array elements unless the user provides a callback 
+ * function. NULL may be passed as an alternative to supplying a callback, but the user must remember to 
+ * delete the array elements afterwards. The user must not delete or deallocate the array elements prior to 
+ * calling this function, as it requires valid elements for memory reference decrementation operations.
+ *
+ * @return void
  *
  */
 void psVoidPtrArrayFree(
-    psVoidPtrArray *restrict psArr,     ///< Array to destroy.
-    void (*elemFree)(void *)            ///< Callback function responsible for removing array data.
+    psArray *restrict psArr,            ///< Void pointer array to destroy.
+    void (*elemFree)(void *)            ///< Optional callback function to remove array elements.
 );
 
Index: /trunk/psLib/src/collections/psBitSet.c
===================================================================
--- /trunk/psLib/src/collections/psBitSet.c	(revision 577)
+++ /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';
     }
 
Index: /trunk/psLib/src/collections/psBitSet.h
===================================================================
--- /trunk/psLib/src/collections/psBitSet.h	(revision 577)
+++ /trunk/psLib/src/collections/psBitSet.h	(revision 578)
@@ -1,20 +1,21 @@
-/** @file  psBitMask.h
+/** @file  psBitSet.h
  *
- *  @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:56 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
 
-#ifndef PSBITMASK_H
-#define PSBITMASK_H
+#ifndef PSBITSET_H
+#define PSBITSET_H
 
 /******************************************************************************/
@@ -22,8 +23,8 @@
 /******************************************************************************/
 
-/** Struct containing array of bits and its length.
+/** Struct containing array of bytes to hold bit data and corresponding array length.
  *
  *  The bits in the struct are assembled in as an array of bytes with eight bits per byte. The bits are 
- *  arranged with the LSB in first position of the first array element.
+ *  arranged with the LSB in first (right most) position of the first array element.
  */
 typedef struct
@@ -32,5 +33,5 @@
     char *bits; /**< Aray of bytes holding bits */
 }
-psBitMask;
+psBitSet;
 
 /*****************************************************************************/
@@ -38,92 +39,73 @@
 /*****************************************************************************/
 
-/** Allocate a psBitMask.
+/** Allocate a psBitSet.
  *
- *  Create a psBitMask with number of bytes specified by the user. All bits are set to zero upon allocation.
+ *  Create a psBitSet with the number of bytes specified by the user. All bits are set to zero upon 
+ *  allocation.
  *
- *  @return  psBitMask*: Pointer to struct containing array of bits and size of array.
+ *  @return  psBitSet*: Pointer to struct containing array of bits and size of array.
  */
-psBitMask* psBitMaskAlloc(
-    int n   /**< Number of bytes in array */
+psBitSet* psBitSetAlloc(
+    int n   /**< Number of bytes in psBitSet array */
 );
 
-/** Free a psBitMask
+/** Free a psBitSet
  *
- *  Deletes a psBitMask array and its byte count.
+ *  Deletes a psBitSet array.
  */
-void psBitMaskFree(
-    psBitMask *restrict inMask  /**< Pointer to psBitMask struct to be deleted. */
+void psBitSetFree(
+    psBitSet *restrict inMask  /**< Pointer to psBitSet to be deleted. */
 );
 
 /** Set a bit.
  *
- *  Sets a bit at a given bit location. The bit is set based on a zero index with the first bit set in 
- *  the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in an array with
- *  two elements would result in an psBitMask that looks like 00000000 00001000.
+ *  Sets a bit at a given bit location, either one or zero. The bit is set based on a zero index with the 
+ *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
+ *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
  *
- *  @return  psBitMask*: Pointer to struct containing array with bit set.
+ *  @return  psBitSet*: Pointer to struct containing psBitSet.
  */
-psBitMask* psBitMaskSet(
-    psBitMask *inMask, /**< Pointer to struct to be set. */
-    int bit            /**< Bit to be set. */
+psBitSet* psBitSetSet(
+    psBitSet *restrict inMask,  /**< Pointer to psBitSet to be set. */
+    int bit                     /**< Bit to be set. */
 );
 
 /** Test the value of a bit.
  *
- *  Prints the value of a bit at a given bit location. The bit printed based on a zero index with the first 
- *  bit set in the zero bit slot of the zero element of the byte array. As an example, testing bit 3 in an array with
- *  two elements that looks like 00000000 00001000 would retrun a value of one, since that value was already set.
+ *  Prints the value of a bit at a given bit location, either one or zero. The resulting bit is based on a 
+ *  zero index format with the first bit set in the zero bit slot of the zero element of the byte array 
+ *  As an example, testing bit 3 in a psBitSet with two bytes that looks like 00000000 00001000 would return a
+ *  value of one, since that is the value that was set.
  *
  *  @return  int: Value of bit, either one or zero.
  */
-int psBitMaskTest(
-    const psBitMask *inMask,    /**< Pointer to struct to be tested. */
-    int bit                     /**< Bit to be tested. */
+int psBitSetTest(
+    const psBitSet *restrict inMask,    /**< Pointer psBitSet to be tested. */
+    int bit                             /**< Bit to be tested. */
 );
 
-/** Perform a binary operation on two psBitMasks
+/** Perform a binary operation on two psBitSets
  *
- *  Perform an AND, OR, or XOR on two psBitMasks. If the BitMasks are not the same size, the operation will not
- *  be performed and an error message will be printed.
+ *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size, the operation will not
+ *  be performed and an error message will be logged.
  *
- *  @return  psBitMask*: Pointer to struct containing result of binary operation.
+ *  @return  psBitSet*: Pointer to struct containing result of binary operation.
  */
-psBitMask* psBitMaskOp(
-    psBitMask *outMask,                 /**< Resulting psBitMask from binary operation */
-    const psBitMask *restrict inMask1,  /**< First psBitMask on which to operate */
-    char *operator,                     /**< Bit operation */
-    const psBitMask *restrict inMask2   /**< First psBitMask on which to operate */
+psBitSet* psBitSetOp(
+    psBitSet *restrict outMask,        /**< Resulting psBitSet from binary operation */
+    const psBitSet *restrict inMask1,  /**< First psBitSet on which to operate */
+    char *operator,                    /**< Bit operation */
+    const psBitSet *restrict inMask2   /**< First psBitSet on which to operate */
 );
 
-/** Print the contents of a psBitMask.
+/** Convert the psBitSet to a string of ones and zeros.
  *
- *  Prints the contents of a psBitMask in its binary form of ones and zeros. The LSB is the left-most chracter.
+ *  Converts the contents of a psBitSet to a string representation of its binary form of ones and zeros. The
+ *  LSB is the right-most chracter. Each set of eight characters represents one byte.
  *
- *  @return  char*: Pointer to character array containing binary formatted data.
+ *  @return  char*: Pointer to character array containing string data.
  */
-char *psBitMaskToString(
-    const psBitMask *restrict inMask /**< psBitMask to print */
-);
-
-/** 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,                            /**< Bit to index to search. */
-    const psBitMask *restrict inMask    /**< psBitMask to search. */
-);
-
-/** 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 /**< Bit to set within mask */
+char *psBitSetToString(
+    const psBitSet *restrict inMask /**< psBitSet to convert */
 );
 
Index: /trunk/psLib/src/collections/psSort.c
===================================================================
--- /trunk/psLib/src/collections/psSort.c	(revision 577)
+++ /trunk/psLib/src/collections/psSort.c	(revision 578)
@@ -14,6 +14,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-21 00:40:32 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -104,7 +104,7 @@
 /*****************************************************************************/
 
-psFloatArray *psSort(
-    psFloatArray *restrict outArray,        /**< Sorted output array. */
-    const psFloatArray *restrict inArray    /**< Input array to sort. */
+psArray *psSort(
+    psArray *restrict outArray,        /**< Sorted output array. */
+    const psArray *restrict inArray    /**< Input array to sort. */
 )
 {
@@ -129,6 +129,6 @@
     inN = inArray->n;
     outN = outArray->n;
-    inArr = inArray->arr;
-    outArr = outArray->arr;
+    inArr = inArray->arr.fltArr;
+    outArr = outArray->arr.fltArr;
     elSize = sizeof(float);
 
@@ -139,4 +139,14 @@
     }
 
+    if(inN == 0) {
+        psError(__func__, " : Line %d - No elements in use for input array\n", __LINE__);
+        return outArray;
+    }
+
+    if(outN == 0) {
+        psError(__func__, " : Line %d - No elements in use for output array\n", __LINE__);
+        return outArray;
+    }
+
     // Copy input array values into output array
     for(i=0; i<inN; i++) {
@@ -150,7 +160,7 @@
 }
 
-psIntArray *psSortIndex(
-    psIntArray *restrict outArray,          /**< Output array of sorted indices. */
-    const psFloatArray *restrict inArray    /**< Input array to be sorted. */
+psArray *psSortIndex(
+    psArray *restrict outArray,         /**< Output array of sorted indices. */
+    const psArray *restrict inArray     /**< Input array to be sorted. */
 )
 {
@@ -163,5 +173,5 @@
     int *outArr = NULL;
     float diff = 0.0f;
-    psFloatArray *tmpFloatArray = NULL;
+    psArray *tmpFloatArray = NULL;
 
     if(outArray == NULL) {
@@ -178,6 +188,6 @@
     inN = inArray->n;
     outN = outArray->n;
-    inArr = inArray->arr;
-    outArr = outArray->arr;
+    inArr = inArray->arr.fltArr;
+    outArr = outArray->arr.intArr;
 
     if(inN != outN) {
@@ -188,8 +198,9 @@
 
     tmpFloatArray = psFloatArrayAlloc(inN);
+    tmpFloatArray->n = inN;
     tmpFloatArray = psSort(tmpFloatArray, inArray);
 
     for(i=0; i<inN; i++) {
-        tempVal = tmpFloatArray->arr[i];
+        tempVal = tmpFloatArray->arr.fltArr[i];
         for(j=0; j<inN; j++) {
             diff = fabsf(tempVal - inArr[j]);
Index: /trunk/psLib/src/collections/psSort.h
===================================================================
--- /trunk/psLib/src/collections/psSort.h	(revision 577)
+++ /trunk/psLib/src/collections/psSort.h	(revision 578)
@@ -14,10 +14,10 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-19 20:10:46 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
- 
+
 #ifndef PSSORT_H
 #define PSSORT_H
@@ -38,5 +38,5 @@
 /* FUNCTION PROTOTYPES                                                       */
 /*****************************************************************************/
- 
+
 /** Sort an array of floats.
  *
@@ -46,5 +46,5 @@
  */
 
-psFloatArray *psSort(psFloatArray *restrict out, const psFloatArray *restrict inArray);
+psArray *psSort(psArray *restrict out, const psArray *restrict inArray);
 
 /** Creates an array of indices based on sort odred of float array.
@@ -56,5 +56,5 @@
  */
 
-psIntArray *psSortIndex(psIntArray *restrict out, const psFloatArray *restrict inArray);
+psArray *psSortIndex(psArray *restrict out, const psArray *restrict inArray);
 
 #endif
Index: /trunk/psLib/src/types/psArray.c
===================================================================
--- /trunk/psLib/src/types/psArray.c	(revision 577)
+++ /trunk/psLib/src/types/psArray.c	(revision 578)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-22 21:15:01 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:22 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -48,10 +48,12 @@
 /*****************************************************************************/
 
-static void* p_psArrayAlloc(psType *arrType, psElemType elemType, int nalloc, int elemSize)
+static void* p_psArrayAlloc(psArray *restrict psArr, psElemType elemType, int nalloc, int elemSize)
 {
     void *arr = NULL;
 
-    arrType->dimen = PS_DIMEN_VECTOR;
-    arrType->type = elemType;
+    psArr->type.dimen = PS_DIMEN_VECTOR;
+    psArr->type.type = elemType;
+    psArr->nalloc = nalloc;
+    psArr->n = 0;
 
     if(nalloc != 0) {
@@ -62,209 +64,158 @@
 }
 
-static psVoidPtrArray *p_psVoidPtrArrayRealloc(psVoidPtrArray *restrict psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
+static void* p_psArrayRealloc(psArray *restrict psArr, void *arr, int nalloc, int elemSize)
+{
+    // For decrease in psArray size
+    if(nalloc < psArr->n) {
         psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(void*));   // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(void*));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
+    }
+
+    psArr->nalloc = nalloc;
+
+    return psRealloc(arr, nalloc*elemSize);
+}
+
+/*****************************************************************************/
+/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+/*****************************************************************************/
+psArray* psIntArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.intArr = (int*)p_psArrayAlloc(psArr, PS_TYPE_INT, nalloc, sizeof(int));
+    return psArr;
+}
+
+psArray *psIntArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psIntArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.intArr = p_psArrayRealloc(psArr, psArr->arr.intArr, nalloc, sizeof(int));
+    }
+
+    return psArr;
+}
+
+void psIntArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+
+    psFree(psArr->arr.intArr);
+    psFree(psArr);
+}
+
+psArray* psFloatArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.fltArr = (float*)p_psArrayAlloc(psArr, PS_TYPE_FLOAT, nalloc, sizeof(float));
+    return psArr;
+}
+
+psArray *psFloatArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psFloatArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.fltArr = p_psArrayRealloc(psArr, psArr->arr.fltArr, nalloc, sizeof(float));
+    }
+
+    return psArr;
+}
+
+void psFloatArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    psFree(psArr->arr.fltArr);
+    psFree(psArr);
+}
+
+psArray* psDoubleArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.dblArr = (double*)p_psArrayAlloc(psArr, PS_TYPE_DOUBLE, nalloc, sizeof(double));
+    return psArr;
+}
+
+psArray *psDoubleArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psDoubleArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.dblArr = p_psArrayRealloc(psArr, psArr->arr.dblArr, nalloc, sizeof(double));
+    }
+
+    return psArr;
+}
+
+void psDoubleArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    psFree(psArr->arr.dblArr);
+    psFree(psArr);
+}
+
+psArray* psComplexArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.cFltArr = (complex float*)p_psArrayAlloc(psArr, PS_TYPE_COMPLEX, nalloc, sizeof(complex float));
+    return psArr;
+}
+
+psArray *psComplexArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
+        psArr = psComplexArrayAlloc(nalloc);
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.cFltArr = p_psArrayRealloc(psArr, psArr->arr.cFltArr, nalloc, sizeof(complex float));
+    }
+
+    return psArr;
+}
+
+void psComplexArrayFree(psArray *restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+    psFree(psArr->arr.cFltArr);
+    psFree(psArr);
+}
+
+psArray* psVoidPtrArrayAlloc(int nalloc)
+{
+    psArray *psArr = NULL;
+    psArr = psAlloc(sizeof(psArray));
+    psArr->arr.ptrArr = p_psArrayAlloc(psArr, PS_TYPE_OTHER, nalloc, sizeof(void *));
+    return psArr;
+}
+
+psArray *psVoidPtrArrayRealloc(psArray *restrict psArr, int nalloc)
+{
+    int i = 0;
+
+    for (i = nalloc; i < psArr->n; i++) {               // For reduction in array size
+        psMemDecrRefCounter(psArr->arr.ptrArr[i]);
+    }
+
+    if(psArr == NULL) {                                 // For creating new psArray with realloc
         psArr = psVoidPtrArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-static void p_psVoidPtrArrayFree(psVoidPtrArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-/*****************************************************************************/
-/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
-/*****************************************************************************/
-
-psIntArray* psIntArrayAlloc(int nalloc)
-{
-    psIntArray *psArr = NULL;
-    psArr = (psIntArray*)psAlloc(sizeof(psIntArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (int*)p_psArrayAlloc(&psArr->type, PS_TYPE_INT, nalloc, sizeof(int));
-
-    return psArr;
-}
-
-psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(int));     // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(int));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
-        psArr = psIntArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psIntArrayFree(psIntArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psFloatArray* psFloatArrayAlloc(int nalloc)
-{
-    psFloatArray *psArr = NULL;
-    psArr = (psFloatArray*)psAlloc(sizeof(psFloatArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (float*)p_psArrayAlloc(&psArr->type, PS_TYPE_FLOAT, nalloc, sizeof(float));
-
-    return psArr;
-}
-
-psFloatArray *psFloatArrayRealloc(psFloatArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(float));   // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(float));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
-        psArr = psFloatArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psFloatArrayFree(psFloatArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psDoubleArray* psDoubleArrayAlloc(int nalloc)
-{
-    psDoubleArray *psArr = NULL;
-    psArr = (psDoubleArray*)psAlloc(sizeof(psDoubleArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (double*)p_psArrayAlloc(&psArr->type, PS_TYPE_DOUBLE, nalloc, sizeof(double));
-
-    return psArr;
-}
-
-psDoubleArray *psDoubleArrayRealloc(psDoubleArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                         // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(double));  // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(double));
-    } else if(psArr == NULL) {                                      // For creating new psArray with realloc
-        psArr = psDoubleArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psDoubleArrayFree(psDoubleArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psComplexArray* psComplexArrayAlloc(int nalloc)
-{
-    psComplexArray *psArr = NULL;
-    psArr = (psComplexArray*)psAlloc(sizeof(psComplexArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (complex float*)p_psArrayAlloc(&psArr->type, PS_TYPE_COMPLEX, nalloc, sizeof(complex float));
-
-    return psArr;
-}
-
-psComplexArray *psComplexArrayRealloc(psComplexArray *psArr, int nalloc)
-{
-    if(nalloc < psArr->n) {                                                 // For decrease in psArray size
-        psArr->n = nalloc;
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(complex float));   // For increase in psArray size
-    } else if(nalloc > psArr->nalloc) {
-        psArr->nalloc = nalloc;
-        psArr->arr = psRealloc(psArr->arr, nalloc*sizeof(complex float));
-    } else if(psArr == NULL) {                                              // For creating new psArray with realloc
-        psArr = psComplexArrayAlloc(nalloc);
-    }
-
-    return psArr;
-}
-
-void psComplexArrayFree(psComplexArray *restrict psArr)
-{
-    if (psArr == NULL) {
-        return;
-    }
-    psFree(psArr->arr);
-    psFree(psArr);
-}
-
-psVoidPtrArray* psVoidPtrArrayAlloc(int nalloc)
-{
-    psVoidPtrArray *psArr = NULL;
-    psArr = (psVoidPtrArray*)psAlloc(sizeof(psVoidPtrArray));
-    psArr->nalloc = nalloc;
-    psArr->n = 0;
-    psArr->arr = (void*)p_psArrayAlloc(&psArr->type, PS_TYPE_OTHER, nalloc, sizeof(void*));
-
-    return psArr;
-}
-
-psVoidPtrArray *psVoidPtrArrayRealloc(psVoidPtrArray *restrict psArr, int nalloc, void (*elemFree)(void *))
-{
-    int i = 0;
-
-    if(psArr == NULL) {
-        return psArr;
-    }
-
-    for (i = nalloc; i < psArr->n; i++) {
-        if(elemFree == NULL) {
-            psMemDecrRefCounter(psArr->arr[i]);
-        } else {
-            elemFree(psMemDecrRefCounter(psArr->arr[i]));
-        }
-    }
-
-    return p_psVoidPtrArrayRealloc(psArr, nalloc);
-}
-
-void psVoidPtrArrayFree(psVoidPtrArray *restrict psArr, void (*elemFree)(void *))
+    } else if(psArr->nalloc != nalloc) {                // No need to realloc to same size
+        psArr->arr.ptrArr = p_psArrayRealloc(psArr, psArr->arr.ptrArr, nalloc, sizeof(void *));
+    }
+
+    return psArr;
+}
+
+void psVoidPtrArrayFree(psArray *restrict psArr, void (*elemFree)(void *))
 {
     int i = 0;
@@ -276,10 +227,13 @@
     for(i = 0; i < psArr->nalloc; i++) {
         if(elemFree == NULL) {
-            psMemDecrRefCounter(psArr->arr[i]);
+            psMemDecrRefCounter(psArr->arr.ptrArr[i]);
         } else {
-            elemFree(psMemDecrRefCounter(psArr->arr[i]));
+            elemFree(psMemDecrRefCounter(psArr->arr.ptrArr[i]));
         }
     }
-    p_psVoidPtrArrayFree(psArr);
-}
-
+
+    // Free pointer array
+    psFree(psArr->arr.ptrArr);
+    psFree(psArr);
+}
+
Index: /trunk/psLib/src/types/psArray.h
===================================================================
--- /trunk/psLib/src/types/psArray.h	(revision 577)
+++ /trunk/psLib/src/types/psArray.h	(revision 578)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-04-23 21:33:59 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -75,75 +75,24 @@
 psType;
 
-/** An array of integers.
- *
- * Struct for maintaining an array of integer numbers.
+/** An array of generic primitive types.
+ *
+ * Struct for maintaining an array of frequently used primitive types.
  *
  */
 typedef struct
 {
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Total number of elements available.
-    int n;          ///< Number of elements in use.
-    int *arr;       ///< Array data.
+    psType type;                ///< Type of data.
+    int nalloc;                 ///< Total number of elements available.
+    int n;                      ///< Number of elements in use.
+
+    union {
+        int *intArr;            ///< Integer array.
+        float *fltArr;          ///< Single precision floating point array.
+        double *dblArr;         ///< Double precision floating point array.
+        complex float *cFltArr; ///< Single precision floating pont complex array.
+        void **ptrArr;          ///< Void pointer array.
+    }arr;                       ///< Union with array data.
 }
-psIntArray;
-
-/** An array of floats.
- *
- * Struct for maintaining an array of single precision floating point numbers.
- *
- */
-typedef struct
-{
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Total number of elements available.
-    int n;          ///< Number of elements in use.
-    float *arr;     ///< Array data.
-}
-psFloatArray;
-
-/** An array of doubles.
- *
- * Struct for maintaining an array of double precision floating point numbers.
- *
- */
-typedef struct
-{
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Total number of elements available.
-    int n;          ///< Number of elements in use.
-    double *arr;    ///< Array data.
-}
-psDoubleArray;
-
-/** An array of complex numbers.
- *
- * Struct for maintaining an array of single precision floating point complex numbers.
- *
- */
-typedef struct
-{
-    psType type;        ///< Type of data.
-    int nalloc;         ///< Total number of elements available.
-    int n;              ///< Number of elements in use
-    complex float *arr; ///< Array data.
-}
-psComplexArray;
-
-/** An array of void pointers.
- *
- * Struct for maintaining an array of void pointers. This struct needs a deallocation function that accepts
- * deallocation of the array elements.
- *
- */
-typedef struct
-{
-    psType type;    ///< Type of data.
-    int nalloc;     ///< Number of total elements.
-    int n;          ///< Number of elements in use.
-    void **arr;     ///< Aray data.
-}
-psVoidPtrArray;
-
+psArray;
 
 /*****************************************************************************/
@@ -155,6 +104,8 @@
  * Uses psLib memory allocation functions to create an array of integers as defined by the psIntArray struct. 
  *
- */
-psIntArray *psIntArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psIntArrayAlloc(
     int nalloc  ///< Total number of elements to make available.
 );
@@ -165,7 +116,9 @@
  * struct. 
  *
- */
-psIntArray *psIntArrayRealloc(
-    psIntArray *myArray,    ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psIntArrayRealloc(
+    psArray *myArray,       ///< Array to reallocate.
     int nalloc              ///< Total number of elements to make available.
 );
@@ -177,7 +130,9 @@
  * struct. 
  *
+ * @return void
+ *
  */
 void psIntArrayFree(
-    psIntArray *restrict psArr  ///< Array to free.
+    psArray *restrict psArr  ///< Array to free.
 );
 
@@ -186,6 +141,8 @@
  * Uses psLib memory allocation functions to create an array of floats as defined by the psFloatArray struct. 
  *
- */
-psFloatArray *psFloatArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psFloatArrayAlloc(
     int nalloc  ///< Total number of elements to make available.
 );
@@ -196,7 +153,9 @@
  * struct. 
  *
- */
-psFloatArray *psFloatArrayRealloc(
-    psFloatArray *psArr,    ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psFloatArrayRealloc(
+    psArray *psArr,         ///< Array to reallocate.
     int nalloc              ///< Total number of elements to make available.
 );
@@ -207,7 +166,9 @@
  * struct. 
  *
+ * @return void
+ *
  */
 void psFloatArrayFree(
-    psFloatArray *restrict myArray  ///< Array to free.
+    psArray *restrict myArray  ///< Array to free.
 );
 
@@ -217,6 +178,8 @@
  * struct. 
  *
- */
-psDoubleArray *psDoubleArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psDoubleArrayAlloc(
     int nalloc  ///< Total number of elements to make available.
 );
@@ -227,7 +190,9 @@
  * struct. 
  *
- */
-psDoubleArray *psDoubleArrayRealloc(
-    psDoubleArray *psArr,   ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psDoubleArrayRealloc(
+    psArray *psArr,         ///< Array to reallocate.
     int nalloc              ///< Total number of elements to make available.
 );
@@ -238,7 +203,9 @@
  * struct. 
  *
+ * @return void
+ *
  */
 void psDoubleArrayFree(
-    psDoubleArray *restrict psArr  ///< Array to free.
+    psArray *restrict psArr  ///< Array to free.
 );
 
@@ -248,6 +215,8 @@
  * numbers as defined by the psComplexArray struct.
  *
- */
-psComplexArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available.
 ;
 
@@ -257,7 +226,9 @@
  * numbers as defined by the psComplexArray struct.
  *
- */
-psComplexArray *psComplexArrayRealloc(
-    psComplexArray *myArray,    ///< Array to reallocate.
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psComplexArrayRealloc(
+    psArray *psArr,            ///< Array to reallocate.
     int nalloc                  ///< Total number of elements to make available.
 );
@@ -268,7 +239,9 @@
  * numbers as defined by the psComplexArray struct.
  *
+ * @return void
+ *
  */
 void psComplexArrayFree(
-    psComplexArray *restrict psArr  ///< Array to free.
+    psArray *restrict psArr  ///< Array to free.
 );
 
@@ -278,6 +251,8 @@
  * struct.
  *
- */
-psVoidPtrArray *psVoidPtrArrayAlloc(
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psVoidPtrArrayAlloc(
     int nalloc  ///< Number of elements to use.
 );
@@ -286,11 +261,13 @@
  *
  * Uses psLib memory allocation functions to reallocate an array of void pointers as defined by the 
- * psVoidPtrArray struct.
- *
- */
-psVoidPtrArray *psVoidPtrArrayRealloc(
-    psVoidPtrArray *restrict psArr, ///< Array to reallocate.
-    int nalloc,                     ///< Number of elements.
-    void (*elemFree)(void *)        ///< Callback function responsible for removing array data.
+ * psVoidPtrArray struct. If the array size is increased or decreased, this function does not allocate or 
+ * deallocate the contents of individual array elements. The user must do this after calling this function.
+ *
+ * @return psArray* Pointer to psArray.
+ *
+ */
+psArray *psVoidPtrArrayRealloc(
+    psArray *restrict psArr,        ///< Void pointer array to destroy.
+    int nalloc                      ///< Number of elements.
 );
 
@@ -298,10 +275,15 @@
  *
  * Uses psLib memory allocation functions to deallocate an array of void pointers as defined by the 
- * psVoidPtrArray struct.
+ * psVoidPtrArray struct. This function does not free the array elements unless the user provides a callback 
+ * function. NULL may be passed as an alternative to supplying a callback, but the user must remember to 
+ * delete the array elements afterwards. The user must not delete or deallocate the array elements prior to 
+ * calling this function, as it requires valid elements for memory reference decrementation operations.
+ *
+ * @return void
  *
  */
 void psVoidPtrArrayFree(
-    psVoidPtrArray *restrict psArr,     ///< Array to destroy.
-    void (*elemFree)(void *)            ///< Callback function responsible for removing array data.
+    psArray *restrict psArr,            ///< Void pointer array to destroy.
+    void (*elemFree)(void *)            ///< Optional callback function to remove array elements.
 );
 
Index: /trunk/psLib/src/types/psBitSet.c
===================================================================
--- /trunk/psLib/src/types/psBitSet.c	(revision 577)
+++ /trunk/psLib/src/types/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';
     }
 
Index: /trunk/psLib/src/types/psBitSet.h
===================================================================
--- /trunk/psLib/src/types/psBitSet.h	(revision 577)
+++ /trunk/psLib/src/types/psBitSet.h	(revision 578)
@@ -1,20 +1,21 @@
-/** @file  psBitMask.h
+/** @file  psBitSet.h
  *
- *  @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:56 $
+ *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-05 20:43:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
 
-#ifndef PSBITMASK_H
-#define PSBITMASK_H
+#ifndef PSBITSET_H
+#define PSBITSET_H
 
 /******************************************************************************/
@@ -22,8 +23,8 @@
 /******************************************************************************/
 
-/** Struct containing array of bits and its length.
+/** Struct containing array of bytes to hold bit data and corresponding array length.
  *
  *  The bits in the struct are assembled in as an array of bytes with eight bits per byte. The bits are 
- *  arranged with the LSB in first position of the first array element.
+ *  arranged with the LSB in first (right most) position of the first array element.
  */
 typedef struct
@@ -32,5 +33,5 @@
     char *bits; /**< Aray of bytes holding bits */
 }
-psBitMask;
+psBitSet;
 
 /*****************************************************************************/
@@ -38,92 +39,73 @@
 /*****************************************************************************/
 
-/** Allocate a psBitMask.
+/** Allocate a psBitSet.
  *
- *  Create a psBitMask with number of bytes specified by the user. All bits are set to zero upon allocation.
+ *  Create a psBitSet with the number of bytes specified by the user. All bits are set to zero upon 
+ *  allocation.
  *
- *  @return  psBitMask*: Pointer to struct containing array of bits and size of array.
+ *  @return  psBitSet*: Pointer to struct containing array of bits and size of array.
  */
-psBitMask* psBitMaskAlloc(
-    int n   /**< Number of bytes in array */
+psBitSet* psBitSetAlloc(
+    int n   /**< Number of bytes in psBitSet array */
 );
 
-/** Free a psBitMask
+/** Free a psBitSet
  *
- *  Deletes a psBitMask array and its byte count.
+ *  Deletes a psBitSet array.
  */
-void psBitMaskFree(
-    psBitMask *restrict inMask  /**< Pointer to psBitMask struct to be deleted. */
+void psBitSetFree(
+    psBitSet *restrict inMask  /**< Pointer to psBitSet to be deleted. */
 );
 
 /** Set a bit.
  *
- *  Sets a bit at a given bit location. The bit is set based on a zero index with the first bit set in 
- *  the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in an array with
- *  two elements would result in an psBitMask that looks like 00000000 00001000.
+ *  Sets a bit at a given bit location, either one or zero. The bit is set based on a zero index with the 
+ *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
+ *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
  *
- *  @return  psBitMask*: Pointer to struct containing array with bit set.
+ *  @return  psBitSet*: Pointer to struct containing psBitSet.
  */
-psBitMask* psBitMaskSet(
-    psBitMask *inMask, /**< Pointer to struct to be set. */
-    int bit            /**< Bit to be set. */
+psBitSet* psBitSetSet(
+    psBitSet *restrict inMask,  /**< Pointer to psBitSet to be set. */
+    int bit                     /**< Bit to be set. */
 );
 
 /** Test the value of a bit.
  *
- *  Prints the value of a bit at a given bit location. The bit printed based on a zero index with the first 
- *  bit set in the zero bit slot of the zero element of the byte array. As an example, testing bit 3 in an array with
- *  two elements that looks like 00000000 00001000 would retrun a value of one, since that value was already set.
+ *  Prints the value of a bit at a given bit location, either one or zero. The resulting bit is based on a 
+ *  zero index format with the first bit set in the zero bit slot of the zero element of the byte array 
+ *  As an example, testing bit 3 in a psBitSet with two bytes that looks like 00000000 00001000 would return a
+ *  value of one, since that is the value that was set.
  *
  *  @return  int: Value of bit, either one or zero.
  */
-int psBitMaskTest(
-    const psBitMask *inMask,    /**< Pointer to struct to be tested. */
-    int bit                     /**< Bit to be tested. */
+int psBitSetTest(
+    const psBitSet *restrict inMask,    /**< Pointer psBitSet to be tested. */
+    int bit                             /**< Bit to be tested. */
 );
 
-/** Perform a binary operation on two psBitMasks
+/** Perform a binary operation on two psBitSets
  *
- *  Perform an AND, OR, or XOR on two psBitMasks. If the BitMasks are not the same size, the operation will not
- *  be performed and an error message will be printed.
+ *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size, the operation will not
+ *  be performed and an error message will be logged.
  *
- *  @return  psBitMask*: Pointer to struct containing result of binary operation.
+ *  @return  psBitSet*: Pointer to struct containing result of binary operation.
  */
-psBitMask* psBitMaskOp(
-    psBitMask *outMask,                 /**< Resulting psBitMask from binary operation */
-    const psBitMask *restrict inMask1,  /**< First psBitMask on which to operate */
-    char *operator,                     /**< Bit operation */
-    const psBitMask *restrict inMask2   /**< First psBitMask on which to operate */
+psBitSet* psBitSetOp(
+    psBitSet *restrict outMask,        /**< Resulting psBitSet from binary operation */
+    const psBitSet *restrict inMask1,  /**< First psBitSet on which to operate */
+    char *operator,                    /**< Bit operation */
+    const psBitSet *restrict inMask2   /**< First psBitSet on which to operate */
 );
 
-/** Print the contents of a psBitMask.
+/** Convert the psBitSet to a string of ones and zeros.
  *
- *  Prints the contents of a psBitMask in its binary form of ones and zeros. The LSB is the left-most chracter.
+ *  Converts the contents of a psBitSet to a string representation of its binary form of ones and zeros. The
+ *  LSB is the right-most chracter. Each set of eight characters represents one byte.
  *
- *  @return  char*: Pointer to character array containing binary formatted data.
+ *  @return  char*: Pointer to character array containing string data.
  */
-char *psBitMaskToString(
-    const psBitMask *restrict inMask /**< psBitMask to print */
-);
-
-/** 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,                            /**< Bit to index to search. */
-    const psBitMask *restrict inMask    /**< psBitMask to search. */
-);
-
-/** 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 /**< Bit to set within mask */
+char *psBitSetToString(
+    const psBitSet *restrict inMask /**< psBitSet to convert */
 );
 
