コード例 #1
0
ファイル: predictor.cpp プロジェクト: rhentofs/summit
int Predictor::addPrediction(double predStart, double predEnd, double predStartSd,
							 double predEndSd, double postIO, int pos, int verbose)
{
  // Only add if proper prediction (non-nan)
  if (!gsl_isnan(predStart) && !gsl_isnan(predEnd) && !gsl_isnan(postIO))
    {
      // Empty multimap: just add prediction
      if (starts.empty())
	{
	  starts.insert(createMapPair(predStart, predEnd, postIO, predStartSd, predEndSd, (double)scnt));
	  ends.insert(createMapPair(predEnd, predStart, postIO, predStartSd, predEndSd, (double)ecnt));
	  scnt++;
	  ecnt++;
	}
      // Non-empty multimap
      else
	{
	  multimap<double,Info*,comp>::reverse_iterator end = ends.rbegin();
	  
	  // New prediction sufficiently far away from the old ones?
	  if (pos - end->first >= min(ws,maxD))
	    {
	      this->flush(verbose);
	    }
	  starts.insert(createMapPair(predStart, predEnd, postIO, predStartSd, predEndSd, (double)scnt));
	  ends.insert(createMapPair(predEnd, predStart, postIO, predStartSd, predEndSd, (double)ecnt));
	  scnt++;
	  ecnt++;
	}
    }
  
  return(0);
}
コード例 #2
0
ファイル: OBMap.c プロジェクト: bhuthesh/offbrand_lib
void addToMap(OBMap *m, obj *key, obj *value){

  OBMapPair *mp;
  OBDequeIterator *it;
  obhash_t hash_value;

  assert(m);
  
  hash_value = findKeyInHashTable(m, key);
  it = (OBDequeIterator *)objAtVectorIndex(m->hash_table, hash_value);

  /* If the key already exists in the map then overwrite the existing
   * value */
  if(it){
    mp = (OBMapPair *)objAtDequeIt(m->pairs, it);
    replaceMapPairValue(mp, value);
    return;
  }

  /* if add operation will overload the map then resize the map */
  if((dequeLength(m->pairs)+1)/MAP_CAPACITIES[m->cap_idx] > MAX_LOAD_FACTOR)
    increaseMapSize(m);

  mp = createMapPair(key, value);
  addDequeTail(m->pairs, (obj *)mp);
  release((obj *)mp); /* map deque has only reference to mp */

  assert(it = getDequeTailIt(m->pairs));
  addToHashTable(m, it);
  release((obj *)it); /* map vector hash only reference to it */
  
  return; 
}
コード例 #3
0
ファイル: OBMap.c プロジェクト: bhuthesh/offbrand_lib
OBMapPair * copyMapPair(OBMapPair *mp){
  assert(mp);
  return createMapPair(mp->key, mp->value);
}