int recMarginIncrement(MTree *M, MNode **p, int *key)
     /* Search a node with key/value key.  If found increments
     ** count. If not found add new node to tree. */
{
  register int cmp;
  register MNode *m=*p;

  if ( m == 0 ) {
    /* key not found; add new MNode */
    (*p)=newMNode(M,key);
    return (*p)->idx;
  } else {
    if ( (cmp=veccmp(key,m->key,M->dim)) < 0 ) {
      /* key is smaller then m->key, hence go into left subtree */
      return recMarginIncrement(M,&(m->left),key);
    } else if ( cmp > 0 ) {
      /* key is larger then m->key, hence go into right subtree */
      return recMarginIncrement(M,&(m->right),key);
    } else {
      /* key found! */
      m->count++;
      M->nSamples++;
      return m->idx;
    }
  }
}
Example #2
0
 bool operator<(const VEntry & lhs, const VEntry & rhs) {
     auto cmp = veccmp(lhs.values, rhs.values);
     if (cmp != 0) return cmp < 0;
     if (lhs.action != rhs.action)
         return lhs.action < rhs.action;
     return lhs.observations < rhs.observations;
 }
Example #3
0
  JNIEXPORT jint JNICALL Java_edu_berkeley_bid_CUMACH_veccmp
  (JNIEnv *env, jobject obj, jobject ja, jobject jb, jobject jc)
  {
    int *a = (int*)getPointer(env, ja);
    int *b = (int*)getPointer(env, jb);
    int *c = (int*)getPointer(env, jc);

    return veccmp(a, b, c);
  }
int recMarginSearch(MTree *M, MNode *m, int *key)
     /* Search a node with key/value key.  If found increments
     ** count. If not found add new node to tree. */
{
  register int cmp;

  if ( m == 0 ) {
    /* key not found */
    return -1;
  } else {
    if ( (cmp=veccmp(key,m->key,M->dim)) < 0 ) {
      /* key is smaller then m->key, hence go into left subtree */
      return recMarginSearch(M,m->left,key);
    } else if ( cmp > 0 ) {
      /* key is larger then m->key, hence go into right subtree */
      return recMarginSearch(M,m->right,key);
    } else {
      /* key found! */
      return m->idx;
    }
  }
}
Example #5
0
 bool operator==(const VEntry & lhs, const VEntry & rhs) {
     return veccmp(lhs.values, rhs.values) == 0 &&
            lhs.action == rhs.action &&
            lhs.observations == rhs.observations;
 }