Beispiel #1
0
JSBool JsSite::getName(JSContext *cx,JSObject *obj,uintN argc,jsval *argv,jsval *rval)
{
	Site *site = (Site*)JS_GetPrivate(cx,obj);
	JSString *str = JS_NewStringCopyN(cx,site->getName().c_str(),site->getName().length());
	*rval = STRING_TO_JSVAL(str);

	return JS_TRUE;
}
Beispiel #2
0
// ----------------- METHOD TO ORDER THE LIST IN ASCENDING --------------------//
void orderListSitesAscending(Site *listSites){
    // Convert from a list to Array of web sites
    Site *temp;
    int Nelementos = getSizeOfListSites(listSites);
    Site *arraySites[Nelementos]; int i = 0;
    for(Site *tempSite = listSites; tempSite!=NULL; tempSite = tempSite->sig){
        temp = new Site(tempSite->getName(), tempSite->getAddress());
        temp->setListTokensMatches(tempSite->getListTokensMatches());
        arraySites[i] = temp;
        i++;
    }
    // END listToArray

    int j;                //Variables contadoras del ciclo.
    temp=NULL;             //Variable temporal.

    for (i=1;i<Nelementos;i++)
    {
       for (j=0; j < Nelementos-1 ;j++)
       {
          if (arraySites[j]->getSizeListTokens() < arraySites[j+1]->getSizeListTokens())//Condicion mayor-menor
          {
            temp=arraySites[j];
            arraySites[j]=arraySites[j+1];
            arraySites[j+1]=temp;
          }
       }
    }
    printArraySites(arraySites, Nelementos);
}