IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2008, 7:45:21 AM (18 years ago)
Author:
eugene
Message:

modify functions to use both int and flt vectors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/uniq.c

    r20839 r20857  
    44 
    55  int Nnew, i, j, found;
    6   opihi_flt *v1, *v2;
    76  Vector *ivec, *ovec;
    87
     
    1615
    1716  /* allocate the maximum possible needed */
    18   ALLOCATE (ovec[0].elements.Flt, opihi_flt, ivec[0].Nelements);
     17  ResetVector (out, ivec->type, ivec->Nelements);
    1918
    2019  Nnew = 0;
    21   v1 = ivec[0].elements.Flt;
    22   for (i = 0; i < ivec[0].Nelements; i++, v1++) {
    23     v2 = ovec[0].elements.Flt;
    24     found = FALSE;
    25     for (j = 0; !found && (j < Nnew); j++, v2++) {
    26       if (*v1 == *v2) found = TRUE;
     20
     21  if (ivec->type == OPIHI_FLT) {
     22    opihi_flt *v1 = ivec[0].elements.Flt;
     23    for (i = 0; i < ivec[0].Nelements; i++, v1++) {
     24      opihi_flt *v2 = ovec[0].elements.Flt;
     25      found = FALSE;
     26      for (j = 0; !found && (j < Nnew); j++, v2++) {
     27        if (*v1 == *v2) found = TRUE;
     28      }
     29      if (!found) {
     30        ovec[0].elements.Flt[Nnew] = *v1;
     31        Nnew ++;
     32      }
    2733    }
    28     if (!found) {
    29       ovec[0].elements.Flt[Nnew] = *v1;
    30       Nnew ++;
     34  } else {
     35    opihi_int *v1 = ivec[0].elements.Int;
     36    for (i = 0; i < ivec[0].Nelements; i++, v1++) {
     37      opihi_int *v2 = ovec[0].elements.Int;
     38      found = FALSE;
     39      for (j = 0; !found && (j < Nnew); j++, v2++) {
     40        if (*v1 == *v2) found = TRUE;
     41      }
     42      if (!found) {
     43        ovec[0].elements.Int[Nnew] = *v1;
     44        Nnew ++;
     45      }
    3146    }
    3247  }
    3348
    34   ovec[0].Nelements = Nnew;
    35   REALLOCATE (ovec[0].elements.Flt, opihi_flt, ovec[0].Nelements);
     49  // free up extra memory
     50  ResetVector (out, ivec->type, Nnew);
    3651
    3752  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.