// -------------------------------------------------------------------------
// QueryInfo Class :: inRange() - match check having a range
// -------------------------------------------------------------------------
IBase :: Boolean QueryInfo :: inRange(const IString &c1
                                     ,const IString &c2
                                     ,const IString &range)
{

   if (c2.length() == 0)
      return false;

    IString matchItem, compareItem;

    matchItem   = chopOff(c1);
    compareItem = chopOff(c2);

   if ( (c1.isDigits()) && (c2.isDigits()) ) {
      // compare 2 numbers
      long d1=c1.asInt();
      long d2=c2.asInt();
      return compareIt(d1, d2, range);
   }
   else {
      ADate *date1 = new ADate(c1);
      ADate *date2 = new ADate(c2);
      return compareIt(date1, date2, range);
   } /* endif */

};
Пример #2
0
static void rTreeTraverseRange(struct rbTreeNode *n)
/* Recursively traverse tree in range applying doIt. */
{
if (n != NULL)
   {
   int minCmp = compareIt(n->item, minIt);
   int maxCmp = compareIt(n->item, maxIt);
   if (minCmp >= 0)
       rTreeTraverseRange(n->left);
   if (minCmp >= 0 && maxCmp <= 0)
       doIt(n->item);
   if (maxCmp <= 0)
       rTreeTraverseRange(n->right);
   }
}
Пример #3
0
static void rTreeTraverseRange(struct rbTreeNode *n)
/* Recursively traverse tree applying doIt to items between minIt and maxIt. */
{
if (n != NULL)
   {
   rbmTreeCompareResult minCmp = compareIt(n->item, minIt);
   rbmTreeCompareResult maxCmp = compareIt(n->item, maxIt);
   if (minCmp != RBMT_LESS)
       rTreeTraverseRange(n->left);
   if (minCmp != RBMT_LESS && maxCmp != RBMT_GREATER)
       doIt(n->item);
   if (maxCmp != RBMT_GREATER)
       rTreeTraverseRange(n->right);
   }
}
Пример #4
0
Файл: main.c Проект: msskmlrn/C
int compareGen(const void *block1, const void *block2, size_t elemSize,
        size_t block1Size, size_t block2Size, int (*compareIt) (const void*, const void*)) {
    
    for (unsigned int i = 0; i < block1Size && i < block2Size; i++) {
        if (compareIt((void*)((char*)block1 + elemSize * i), (void*)((char*)block2 + elemSize * i)) != 0)
            return compareIt((void*)((char*)block1 + i * elemSize), (void*)((char*)block2 + i * elemSize));
    }
    
    if (block1Size > block2Size)
        return 1;
    
    else if (block2Size > block1Size)
        return -1;
    
    return 0;
}