Changeset 20936 for trunk/Ohana/src/opihi/cmd.data/uniq.c
- Timestamp:
- Dec 7, 2008, 3:31:01 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/uniq.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/uniq.c
r7917 r20936 4 4 5 5 int Nnew, i, j, found; 6 float *v1, *v2;7 6 Vector *ivec, *ovec; 8 7 … … 16 15 17 16 /* allocate the maximum possible needed */ 18 ALLOCATE (ovec[0].elements, float, ivec[0].Nelements);17 ResetVector (ovec, ivec->type, ivec->Nelements); 19 18 20 19 Nnew = 0; 21 v1 = ivec[0].elements; 22 for (i = 0; i < ivec[0].Nelements; i++, v1++) { 23 v2 = ovec[0].elements; 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 } 27 33 } 28 if (!found) { 29 ovec[0].elements[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 } 31 46 } 32 47 } 33 48 34 ovec[0].Nelements = Nnew;35 R EALLOCATE (ovec[0].elements, float, ovec[0].Nelements);49 // free up extra memory 50 ResetVector (ovec, ivec->type, Nnew); 36 51 37 52 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
