IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 12, 2005, 9:34:34 AM (21 years ago)
Author:
eugene
Message:

pcontrol dev

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/QueueOps.c

    r3187 r3203  
    22
    33/* get object from point in stack (negative == distance from end) */
    4 void *GetQueue (Queue *queue, int where) {
     4void *GetStack (Stack *stack, int where) {
    55
    66  int i;
    77  void *object;
    88 
    9   /* QUEUE_TOP == 0, QUEUE_BOTTOM == -1 */
     9  /* STACK_TOP == 0, STACK_BOTTOM == -1 */
    1010  /* this code correctly handles the negative 'where' and Nobject == 0 */
    11   if (where < 0) where += queue[0].Nobject;
     11  if (where < 0) where += stack[0].Nobject;
    1212  if (where < 0) return (NULL);
    13   if (where >= queue[0].Nobject) return (NULL);
     13  if (where >= stack[0].Nobject) return (NULL);
    1414
    15   object = queue[0].object[where];
    16   queue[0].Nobject --;
    17   for (i = where; i < queue[0].Nobject; i++) {
    18     queue[0].object[i] = queue[0].object[i+1];
     15  object = stack[0].object[where];
     16  stack[0].Nobject --;
     17  for (i = where; i < stack[0].Nobject; i++) {
     18    stack[0].object[i] = stack[0].object[i+1];
    1919  }
    2020  return (object);
     
    2222
    2323/* push object on top of stack */
    24 int PutQueue (Queue *queue, int where, void *object) {
     24int PutStack (Stack *stack, int where, void *object) {
    2525
    2626  int i;
    2727
    28   /* QUEUE_TOP == 0, QUEUE_BOTTOM == -1 */
     28  /* STACK_TOP == 0, STACK_BOTTOM == -1 */
    2929  /* this code correctly handles the negative 'where' and Nobject == 0 */
    30   if (where < 0) where += queue[0].Nobject + 1;
     30  if (where < 0) where += stack[0].Nobject + 1;
    3131  if (where < 0) return (FALSE);
    32   if (where > queue[0].Nobject) return (FALSE);
     32  if (where > stack[0].Nobject) return (FALSE);
    3333
    34   /* extend queue as needed */
    35   if (queue[0].Nobject >= queue[0].NOBJECT) {
    36     queue[0].NOBJECT += 100;
    37     REALLOCATE (queue[0].object, void *, queue[0].NOBJECT);
     34  /* extend stack as needed */
     35  if (stack[0].Nobject >= stack[0].NOBJECT) {
     36    stack[0].NOBJECT += 100;
     37    REALLOCATE (stack[0].object, void *, stack[0].NOBJECT);
    3838  }
    3939
    40   for (i = queue[0].Nobject; i > where; i--) {
    41     queue[0].object[i] = queue[0].object[i-1];
     40  for (i = stack[0].Nobject; i > where; i--) {
     41    stack[0].object[i] = stack[0].object[i-1];
    4242  }
    43   queue[0].object[where] = object;
    44   queue[0].Nobject ++;
     43  stack[0].object[where] = object;
     44  stack[0].Nobject ++;
    4545  return (TRUE);
    4646}
    4747
    48 /* allocate queue, setup with default values, allocate data */
    49 Queue *InitQueue () {
     48/* allocate stack, setup with default values, allocate data */
     49Stack *InitStack () {
    5050
    51   Queue *queue;
     51  Stack *stack;
    5252
    53   ALLOCATE (queue, Queue, 1);
     53  ALLOCATE (stack, Stack, 1);
    5454
    55   queue[0].Nobject = 0;
    56   queue[0].NOBJECT = 50;
    57   ALLOCATE (queue[0].object, void *, queue[0].NOBJECT);
    58   return (queue);
     55  stack[0].Nobject = 0;
     56  stack[0].NOBJECT = 50;
     57  ALLOCATE (stack[0].object, void *, stack[0].NOBJECT);
     58  return (stack);
    5959}
    6060
    61 /* these queues are not super efficient, and should probably be replaced with linked lists,
     61/* these stacks are not super efficient, and should probably be replaced with linked lists,
    6262   but I find these easier to get my brain around
    6363*/
Note: See TracChangeset for help on using the changeset viewer.