IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psList.c

    r1807 r2204  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-09-14 20:01:52 $
     8 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-10-27 00:57:31 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1313
    1414#include <stdlib.h>
    15 #include <stdbool.h>
    1615#include <stdio.h>
    1716#include <pthread.h>                       // we need a mutex to make this stuff thread safe.
     
    2625#include "psCollectionsErrors.h"
    2726
    28 #define ITER_INIT_HEAD ((void *)1)         // next iteration should return head
    29 #define ITER_INIT_TAIL ((void *)2)         // next iteration should return tail
     27#define ITER_INIT_HEAD ((psPtr )1)         // next iteration should return head
     28#define ITER_INIT_TAIL ((psPtr )2)         // next iteration should return tail
    3029
    3130// private functions.
    3231static psListElem* listGetIterator(psList* list);
    33 static int listGetIteratorIndex(psList* list);
    34 static void listSetIterator(psList* list, int where, bool lockList);
     32static psS32 listGetIteratorIndex(psList* list);
     33static void listSetIterator(psList* list, psS32 where, psBool lockList);
    3534static void listFree(psList* list);
    3635
    37 psList* psListAlloc(void *data)
     36psList* psListAlloc(psPtr data)
    3837{
    3938    psList* list = psAlloc(sizeof(psList));
     
    8281}
    8382
    84 bool psListAdd(psList* list, int location, void *data)
     83psBool psListAdd(psList* list, psS32 location, psPtr data)
    8584{
    8685    psListElem* position;
    8786    psListElem* elem;
    88     int cursorIndex = 0;
     87    psS32 cursorIndex = 0;
    8988
    9089    if (list == NULL) {
     
    168167 * Remove an element from a list
    169168 */
    170 bool psListRemove(psList* list, int location, void *data)
     169psBool psListRemove(psList* list, psS32 location, psPtr data)
    171170{
    172171    psListElem* elem = NULL;    // element to remove
    173     int cursorIndex = 0;
     172    psS32 cursorIndex = 0;
    174173
    175174    if (list == NULL) {
     
    184183        // search list for the data item.
    185184
    186         int i = 0;              // index
     185        psS32 i = 0;              // index
    187186
    188187        for (psListElem* ptr = list->head; ptr != NULL; ptr = ptr->next) {
     
    247246}
    248247
    249 void psListSetIterator(psList* list, int where)
     248void psListSetIterator(psList* list, psS32 where)
    250249{
    251250    listSetIterator(list, where, true);
    252251}
    253252
    254 static void listSetIterator(psList* list, int where, bool lockList)
     253static void listSetIterator(psList* list, psS32 where, psBool lockList)
    255254{
    256255    psListElem* cursor;
    257     int position;
     256    psS32 position;
    258257
    259258    if (list == NULL) {
     
    272271    }
    273272
    274     if (where >= (int)list->size) {
     273    if (where >= (psS32)list->size) {
    275274        list->iter = NULL;
    276275        if (lockList) {
     
    323322            }
    324323
    325             int position = listGetIteratorIndex(list);
     324            psS32 position = listGetIteratorIndex(list);
    326325
    327326            if (where < position) {
    328                 int diff = position - where;
    329 
    330                 for (int count = 0; count < diff; count++) {
     327                psS32 diff = position - where;
     328
     329                for (psS32 count = 0; count < diff; count++) {
    331330                    listSetIterator(list, PS_LIST_PREVIOUS, false);
    332331                }
    333332            } else {
    334                 int diff = where - position;
    335 
    336                 for (int count = 0; count < diff; count++) {
     333                psS32 diff = where - position;
     334
     335                for (psS32 count = 0; count < diff; count++) {
    337336                    listSetIterator(list, PS_LIST_NEXT, false);
    338337                }
     
    363362}
    364363
    365 int listGetIteratorIndex(psList* list)
     364psS32 listGetIteratorIndex(psList* list)
    366365{
    367366    if (list->iter == ITER_INIT_HEAD) {
     
    374373}
    375374
    376 void *psListGet(psList* list, int location)
     375psPtr psListGet(psList* list, psS32 location)
    377376{
    378377    psListElem* element;
     
    391390 * and now return the previous/next element of the list
    392391 */
    393 void *psListGetNext(psList* list)
     392psPtr psListGetNext(psList* list)
    394393{
    395394    return psListGet(list, PS_LIST_NEXT);
    396395}
    397396
    398 void *psListGetPrevious(psList* list)
     397psPtr psListGetPrevious(psList* list)
    399398{
    400399    return psListGet(list, PS_LIST_PREVIOUS);
    401400}
    402401
    403 void *psListGetCurrent(psList* list)
     402psPtr psListGetCurrent(psList* list)
    404403{
    405404    return psListGet(list, PS_LIST_CURRENT);
     
    412411{
    413412    psListElem* ptr;
    414     unsigned int n;
     413    psU32 n;
    415414    psArray* restrict arr;
    416415
     
    429428    ptr = list->head;
    430429    n = list->size;
    431     for (int i = 0; i < n; i++) {
     430    for (psS32 i = 0; i < n; i++) {
    432431        arr->data[i] = psMemIncrRefCounter(ptr->data);
    433432        ptr = ptr->next;
     
    439438psList* psArrayToList(psArray* arr)
    440439{
    441     unsigned int n;
     440    psU32 n;
    442441    psList* list;               // list of elements
    443442
     
    448447    list = psListAlloc(NULL);
    449448    n = arr->n;
    450     for (int i = 0; i < n; i++) {
     449    for (psS32 i = 0; i < n; i++) {
    451450        psListAdd(list, PS_LIST_TAIL, arr->data[i]);
    452451    }
Note: See TracChangeset for help on using the changeset viewer.