IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 5, 2004, 10:43:57 AM (22 years ago)
Author:
harman
Message:

Updated per SDR documentation bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psBitSet.h

    r542 r578  
    1 /** @file  psBitMask.h
     1/** @file  psBitSet.h
    22 *
    3  *  @brief Creates an array of bits of arbitrary length.
     3 *  @brief Creates an array of bytes of arbitrary length for storing individual bits.
    44 *
    5  *  Bit masks are useful for turning options on and off. This module provides functions to create an array of
    6  *  bits of arbitrary length and manipulate them with basic binary operations. A print function is also
    7  *  provided to display the entire set of bits in binary form.
     5 *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
     6 *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary
     7 *  operations. A print function is also provided to display the entire set of bits in binary format as a
     8 *  string.
    89 *
    910 *  @author Ross Harman, MHPCC
    1011 *   
    11  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-04-28 17:47:56 $
     12 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-05-05 20:43:57 $
    1314 *
    1415 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1516 */
    1617
    17 #ifndef PSBITMASK_H
    18 #define PSBITMASK_H
     18#ifndef PSBITSET_H
     19#define PSBITSET_H
    1920
    2021/******************************************************************************/
     
    2223/******************************************************************************/
    2324
    24 /** Struct containing array of bits and its length.
     25/** Struct containing array of bytes to hold bit data and corresponding array length.
    2526 *
    2627 *  The bits in the struct are assembled in as an array of bytes with eight bits per byte. The bits are
    27  *  arranged with the LSB in first position of the first array element.
     28 *  arranged with the LSB in first (right most) position of the first array element.
    2829 */
    2930typedef struct
     
    3233    char *bits; /**< Aray of bytes holding bits */
    3334}
    34 psBitMask;
     35psBitSet;
    3536
    3637/*****************************************************************************/
     
    3839/*****************************************************************************/
    3940
    40 /** Allocate a psBitMask.
     41/** Allocate a psBitSet.
    4142 *
    42  *  Create a psBitMask with number of bytes specified by the user. All bits are set to zero upon allocation.
     43 *  Create a psBitSet with the number of bytes specified by the user. All bits are set to zero upon
     44 *  allocation.
    4345 *
    44  *  @return  psBitMask*: Pointer to struct containing array of bits and size of array.
     46 *  @return  psBitSet*: Pointer to struct containing array of bits and size of array.
    4547 */
    46 psBitMask* psBitMaskAlloc(
    47     int n   /**< Number of bytes in array */
     48psBitSet* psBitSetAlloc(
     49    int n   /**< Number of bytes in psBitSet array */
    4850);
    4951
    50 /** Free a psBitMask
     52/** Free a psBitSet
    5153 *
    52  *  Deletes a psBitMask array and its byte count.
     54 *  Deletes a psBitSet array.
    5355 */
    54 void psBitMaskFree(
    55     psBitMask *restrict inMask  /**< Pointer to psBitMask struct to be deleted. */
     56void psBitSetFree(
     57    psBitSet *restrict inMask  /**< Pointer to psBitSet to be deleted. */
    5658);
    5759
    5860/** Set a bit.
    5961 *
    60  *  Sets a bit at a given bit location. The bit is set based on a zero index with the first bit set in
    61  *  the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in an array with
    62  *  two elements would result in an psBitMask that looks like 00000000 00001000.
     62 *  Sets a bit at a given bit location, either one or zero. The bit is set based on a zero index with the
     63 *  first bit set in the zero bit slot of the zero element of the byte array. As an example, setting bit 3 in
     64 *  an array with two elements would result in an psBitSet that looks like 00000000 00001000.
    6365 *
    64  *  @return  psBitMask*: Pointer to struct containing array with bit set.
     66 *  @return  psBitSet*: Pointer to struct containing psBitSet.
    6567 */
    66 psBitMask* psBitMaskSet(
    67     psBitMask *inMask, /**< Pointer to struct to be set. */
    68     int bit            /**< Bit to be set. */
     68psBitSet* psBitSetSet(
     69    psBitSet *restrict inMask,  /**< Pointer to psBitSet to be set. */
     70    int bit                     /**< Bit to be set. */
    6971);
    7072
    7173/** Test the value of a bit.
    7274 *
    73  *  Prints the value of a bit at a given bit location. The bit printed based on a zero index with the first
    74  *  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
    75  *  two elements that looks like 00000000 00001000 would retrun a value of one, since that value was already set.
     75 *  Prints the value of a bit at a given bit location, either one or zero. The resulting bit is based on a
     76 *  zero index format with the first bit set in the zero bit slot of the zero element of the byte array
     77 *  As an example, testing bit 3 in a psBitSet with two bytes that looks like 00000000 00001000 would return a
     78 *  value of one, since that is the value that was set.
    7679 *
    7780 *  @return  int: Value of bit, either one or zero.
    7881 */
    79 int psBitMaskTest(
    80     const psBitMask *inMask,    /**< Pointer to struct to be tested. */
    81     int bit                     /**< Bit to be tested. */
     82int psBitSetTest(
     83    const psBitSet *restrict inMask,    /**< Pointer psBitSet to be tested. */
     84    int bit                             /**< Bit to be tested. */
    8285);
    8386
    84 /** Perform a binary operation on two psBitMasks
     87/** Perform a binary operation on two psBitSets
    8588 *
    86  *  Perform an AND, OR, or XOR on two psBitMasks. If the BitMasks are not the same size, the operation will not
    87  *  be performed and an error message will be printed.
     89 *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the same size, the operation will not
     90 *  be performed and an error message will be logged.
    8891 *
    89  *  @return  psBitMask*: Pointer to struct containing result of binary operation.
     92 *  @return  psBitSet*: Pointer to struct containing result of binary operation.
    9093 */
    91 psBitMask* psBitMaskOp(
    92     psBitMask *outMask,                 /**< Resulting psBitMask from binary operation */
    93     const psBitMask *restrict inMask1,  /**< First psBitMask on which to operate */
    94     char *operator,                     /**< Bit operation */
    95     const psBitMask *restrict inMask2   /**< First psBitMask on which to operate */
     94psBitSet* psBitSetOp(
     95    psBitSet *restrict outMask,        /**< Resulting psBitSet from binary operation */
     96    const psBitSet *restrict inMask1,  /**< First psBitSet on which to operate */
     97    char *operator,                    /**< Bit operation */
     98    const psBitSet *restrict inMask2   /**< First psBitSet on which to operate */
    9699);
    97100
    98 /** Print the contents of a psBitMask.
     101/** Convert the psBitSet to a string of ones and zeros.
    99102 *
    100  *  Prints the contents of a psBitMask in its binary form of ones and zeros. The LSB is the left-most chracter.
     103 *  Converts the contents of a psBitSet to a string representation of its binary form of ones and zeros. The
     104 *  LSB is the right-most chracter. Each set of eight characters represents one byte.
    101105 *
    102  *  @return  char*: Pointer to character array containing binary formatted data.
     106 *  @return  char*: Pointer to character array containing string data.
    103107 */
    104 char *psBitMaskToString(
    105     const psBitMask *restrict inMask /**< psBitMask to print */
    106 );
    107 
    108 /** Private function to return a byte.
    109  *
    110  *  Finds the byte containing the bit within the byte array.
    111  *
    112  *  @return  char*: Pointer to byte in which bit is contained.
    113  */
    114 static char* getByte(
    115     int bit,                            /**< Bit to index to search. */
    116     const psBitMask *restrict inMask    /**< psBitMask to search. */
    117 );
    118 
    119 /** Private function to create a mask.
    120  *
    121  *  Creates an eight bit mask with the given bit set. All other bits in the byte are zero. The input bit uses
    122  *  zero-based indexing, and is the cumulitive index within the array, not the localized byte's bit position.
    123  *
    124  *  @return  char*: Pointer to byte in which bit is contained.
    125  */
    126 static char mask(
    127     int bit /**< Bit to set within mask */
     108char *psBitSetToString(
     109    const psBitSet *restrict inMask /**< psBitSet to convert */
    128110);
    129111
Note: See TracChangeset for help on using the changeset viewer.