Пример #1
0
// Test case: TestLookUp:2
// This test calls lookUp() for the condition where 
// the query has an AND operator. 
// Tests that summed page frequencies returned are correct 
int TestLookUp2() {
  START_TEST_CASE;
  INVERTED_INDEX* testIndex = NULL;

  int wordHash;
  int wordHash2;
  testIndex = initStructure(testIndex);

  wordHash = hash1("dog") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode = NULL;
  docNode = newDocNode(docNode, 15, 1);

  WordNode* wordNode = NULL;
  wordNode = newWordNode(wordNode, docNode, "dog");
  testIndex->hash[wordHash] = wordNode;


  wordHash2 = hash1("cat") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode2 = NULL;
  docNode2 = newDocNode(docNode2, 15, 2);

  WordNode* wordNode2 = NULL;
  wordNode2 = newWordNode(wordNode2, docNode2, "cat");

  testIndex->hash[wordHash2] = wordNode2;

  char query[1000] = "dog AND cat";
  sanitize(query);

  char* temp[1000];
  BZERO(temp, 1000);

  char* queryList[2];
  BZERO(queryList, 2);

  curateWords(queryList, query);
  SHOULD_BE(strcmp(queryList[0],"dog") == 0);
  SHOULD_BE(strcmp(queryList[1],"AND") == 0);
  SHOULD_BE(strcmp(queryList[2],"cat") == 0);

  DocumentNode* saved[1000];
  BZERO(saved, 1000);
  lookUp(saved, queryList, testIndex);

  SHOULD_BE(saved[0]->document_id == docNode->document_id);
  SHOULD_BE(saved[0]->page_word_frequency == 3);
  
  cleanUpList(saved);
  cleanUpQueryList(queryList);
  BZERO(saved, 1000);

  cleanUpIndex(testIndex);

  END_TEST_CASE;
}
Пример #2
0
void SearchWidget::querySet(){
    emit lookUp(
                keyword_1->text(), this->index.at(columnSelect_1->currentIndex()),
                keyword_2->text(), this->index.at(columnSelect_2->currentIndex()),
                keyword_3->text(), this->index.at(columnSelect_3->currentIndex()),
                keyword_4->text(), this->index.at(columnSelect_4->currentIndex()),
                this->orfList->text(), this->contigList->text(),
                (this->andOR->isChecked() ? AND : OR),
                this->caseSensitive->isChecked()
                );
    this->hide();
}
Пример #3
0
void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg)
{
	bArgument *a = lookUp(ba, arg, -1, -1);

	if (a) {
		bArgDoc *d = a->doc;

		internalDocPrint(d);

		d->done = TRUE;
	}
}
Пример #4
0
void FPcamera::Pitch(const double dt)
{
	if (Application::camera_pitch > 0.0)
	{
		lookUp(dt);
	}

	else if (Application::camera_pitch < 0.0)
	{
		lookDown(dt);
	}
}
Пример #5
0
bool CharMapping::doConversion( const wstring_t& asciiText, wstring_t& unicodeText,
    const string_t& fontName )
{
    bool spacingOnly = true;

    unicodeText.resize(asciiText.size());
    for (size_t i = 0; i < asciiText.size(); ++i) {
        unicodeText[i] = lookUp(asciiText[i], fontName);
        spacingOnly = (spacingOnly && 
            (iswspace(unicodeText[i]) || unicodeText[i] == 1));
    }
    return spacingOnly;
}
Пример #6
0
	void operator () ( GameObject & obj1, GameObject & obj2 )
	{
		CollisionFunctionPtr pHitFunction = lookUp( typeid( obj1 ).name(), typeid( obj2 ).name() );

		if ( pHitFunction )
		{
			pHitFunction( obj1, obj2 );
		}
		else
		{
			throw UnknownCollisionException( obj1, obj2 );
		}
	}
Пример #7
0
void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
{
	int i = 0;

	for (i = 1; i < ba->argc; i++) {  /* skip argv[0] */
		if (ba->passes[i] == 0) {
			/* -1 signal what side of the comparison it is */
			bArgument *a = lookUp(ba, ba->argv[i], pass, -1);
			BA_ArgCallback func = NULL;
			void *data = NULL;

			if (a) {
				func = a->func;
				data = a->data;
			}
			else {
				func = default_cb;
				data = default_data;
			}

			if (func) {
				int retval = func(ba->argc - i, ba->argv + i, data);

				if (retval >= 0) {
					int j;

					/* use extra arguments */
					for (j = 0; j <= retval; j++) {
						ba->passes[i + j] = pass;
					}
					i += retval;
				}
				else if (retval == -1) {
					if (a) {
						if (a->key->pass != -1)
							ba->passes[i] = pass;
					}
					break;
				}
			}
		}
	}
}
Пример #8
0
void CpuStat::statistic(double &user, double &system)
{
    double values[NValues];

    lookUp(values);

    double userDelta = values[User] + values[Nice]
        - procValues[User] - procValues[Nice];
    double systemDelta = values[System] - procValues[System];

    double totalDelta = 0;
    for ( int i = 0; i < NValues; i++ )
        totalDelta += values[i] - procValues[i];

    user = userDelta / totalDelta * 100.0;
    system = systemDelta / totalDelta * 100.0;

    for ( int j = 0; j < NValues; j++ )
        procValues[j] = values[j];
}
Пример #9
0
static void action_A(void) {
	int pos;
	char new_yytext[256];
	extern int inPrefix; /* which mode of VA are we in: SUN_A or A_SUN... */

	if ((pos = search_constant(yytext)) != -1) {
		yylval.i = constants[pos].val;
		yyparse(constants[pos].token);
	} else if ((pos = search_token(yytext)) != -1) {
		yyparse(tokens[pos].token);
	} else { /* it is a variable */
		/* printf("yytext= %s %s %i %i %i\n", yytext, agentName, appAgentName,
		 append_NoAgentName, ScoutAppAgentName); */
		if (*agentName != 0 && appAgentName > 0 && append_NoAgentName > 0
				&& ScoutAppAgentName > 0) { /* for distributed tkEden -- sun */

			new_yytext[0] = '\0';
			if (yytext[0] == '_' && inPrefix) {
				strcat(new_yytext, "_");
				yytext++;
			}
			if (inPrefix)
				strcat(new_yytext, agentName);
			else
				strcat(new_yytext, yytext);
			strcat(new_yytext, "_");
			if (inPrefix)
				strcat(new_yytext, yytext);

			else
				strcat(new_yytext, agentName);
			strcpy(yytext, new_yytext);
		}
		yylval.v = lookUp(yytext);
		yyparse((yylval.v)->type);
	}
}
Пример #10
0
void init_scout(void)
{
    char       *name = "/scout.eden";
    char        fullname[255];
    FILE       *initFile;
    extern char *progname;
    extern int run(short, void *, char *);
    char *envcontents;

    if (yytext == 0)
    	yytext = (char *) emalloc(bufsize * sizeof(int));

    strcpy(fullname, libLocation);
    strcat(fullname, name);

    if ((initFile = fopen(fullname, "r")) == 0) {
    	fprintf(stderr, "%s: can't open %s\n", progname, fullname);
    	exit(1);
    }
    lookUp("screen")->type = DISPVAR;	/* screen is of type display */
    run(FILE_DEV, initFile, name);

    /* pre-define these: if you change these, change also the
       corresponding values in the Eden namespace in scout.init.e
       [Ash] */
    /* These need to be in the constants table if VA is not to mess
       them up, so removed again.  [Ash] */
    /*
    installIntVar("OFF",    0);
    installIntVar("ON",     1);
    installIntVar("MOTION", 2);
    installIntVar("ENTER",  4);
    installIntVar("LEAVE",  8);
    */

}
Пример #11
0
CpuStat::CpuStat()
{
    lookUp(procValues);
}
Пример #12
0
// Test case: TestLookUp:5
// This test calls lookUp() for the condition where 
// the query has both AND and OR
int TestLookUp5() {
  START_TEST_CASE;
  INVERTED_INDEX* testIndex = NULL;

  int wordHash;
  int wordHash2;
  int wordHash3;
  int wordHash4;
  testIndex = initStructure(testIndex);

  wordHash = hash1("dog") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode = NULL;
  docNode = newDocNode(docNode, 15, 1);

  WordNode* wordNode = NULL;
  wordNode = newWordNode(wordNode, docNode, "dog");
  testIndex->hash[wordHash] = wordNode;


  wordHash2 = hash1("cat") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode2 = NULL;
  docNode2 = newDocNode(docNode2, 15, 2);

  WordNode* wordNode2 = NULL;
  wordNode2 = newWordNode(wordNode2, docNode2, "cat");

  testIndex->hash[wordHash2] = wordNode2;

  wordHash3 = hash1("mouse") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode3 = NULL;
  docNode3 = newDocNode(docNode3, 23, 2);

  WordNode* wordNode3 = NULL;
  wordNode3 = newWordNode(wordNode3, docNode3, "mouse");

  testIndex->hash[wordHash3] = wordNode3;

  wordHash4 = hash1("lion") % MAX_NUMBER_OF_SLOTS;
  DocumentNode* docNode4 = NULL;
  docNode4 = newDocNode(docNode4, 23, 2);

  WordNode* wordNode4 = NULL;
  wordNode4 = newWordNode(wordNode4, docNode4, "lion");

  testIndex->hash[wordHash4] = wordNode4;

  char query[1000] = "dog cat OR mouse lion";
  sanitize(query);

  char* temp[1000];
  BZERO(temp, 1000);

  char* queryList[1000];
  BZERO(queryList, 1000);

  curateWords(queryList, query);

  DocumentNode* saved[1000];
  BZERO(saved, 1000);
  lookUp(saved, queryList, testIndex);

  SHOULD_BE(saved[0]->document_id == docNode->document_id);
  SHOULD_BE(saved[0]->page_word_frequency == 3);
  SHOULD_BE(saved[1]->document_id == docNode3->document_id);
  SHOULD_BE(saved[1]->page_word_frequency == 4);
  
  cleanUpList(saved);
  cleanUpQueryList(queryList);
  BZERO(saved, 1000);

  cleanUpIndex(testIndex);

  END_TEST_CASE;
}
Пример #13
0
/**
  Look-up fascade
*/
void Movement::lookUp()						{ lookUp(STEP_SIZE); }
Пример #14
0
void FPcamera::Update(double dt, float heightOffset)
{
	if(myKeys['w'])
	{
		if(myKeys['z'])
		{
			if (!m_bJumping)
			{
				Run(dt, heightOffset);
			}
			else
			{
				Walk(dt, heightOffset);
			}
			myKeys['z'] = false;
		}
		else
		{
			Walk(dt, heightOffset);
		}
		myKeys['w'] = false;
	}

	if(myKeys['s'])
	{
		if(myKeys['z'])
		{
			Run(-dt, heightOffset);
			myKeys['z'] = false;
		}
		else
		{
			Walk(-dt, heightOffset);
		}
		myKeys['s'] = false;
	}

	if(myKeys['a'])
	{
		Strafe(-dt, heightOffset);
		myKeys['a'] = false;
	}

	if(myKeys['d'])
	{
		Strafe(dt, heightOffset);
		myKeys['d'] = false;
	}

	if(myKeys['q'])
	{
		moveUp(dt, 5.f);
		myKeys['q'] = false;
	}

	if(myKeys['e'])
	{
		moveDown(dt, 5.f);
		myKeys['e'] = false;
	}

	if(myKeys[32])
	{
		Jump(dt);
		myKeys[32] = false;
	}

	if(myKeys['c'])
	{
		m_bCrouching = true;
		Crouch(dt, heightOffset);
		myKeys['c'] = false;
	}

	else
	{
		m_bCrouching = false;
		Crouch(-dt, heightOffset);
	}

	if(m_bRecoil)
	{
		static float timer = 0.f;

		lookUp(dt, 20.f);
		timer += (float)dt;

		if (timer >= 0.1f)
		{
			m_bRecoil = false;
			timer = 0.f;
		}
	}

	else if (!m_bRecoil && recoil > 0.f)
	{
		lookDown(dt, 20.f);
	}

	UpdateJump(dt, heightOffset);

	if(Application::camera_pitch != 0)
	{
		Pitch(dt);
	}
	if(Application::camera_yaw != 0)
	{
		Yaw(dt);
	}

	if(myKeys['r'])
	{
		Reset();
		myKeys['r'] = false;
	}
}