Exemple #1
0
View::View(const QString* const PIG_PATH, QWidget *parent) :
    QWidget(parent),
    _PIG_PATH(PIG_PATH),
    setDownloadStatusHidden(false),
    ui(new Ui::View)
{
    ui->setupUi(this);
    
    QObject::connect (ui->sa_covers->verticalScrollBar(), &QScrollBar::valueChanged, [&] {
        pages_handler();
    });

    sc_back = new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(delete_info()));
    sc_back->setEnabled(false);

    QDir target(*_PIG_PATH+"/tmp/covers");
    onLocalCovers = target.entryList(QDir::Files | QDir::NoDotAndDotDot);
    target.setPath(*_PIG_PATH+"/tmp/covers/back");
    onLocalBackCovers = target.entryList(QDir::Files | QDir::NoDotAndDotDot);

    t_download_status = new QTimer(this);

    QObject::connect (t_download_status, &QTimer::timeout, [&] {
        ui->lb_px_download_status->setHidden(setDownloadStatusHidden);
        setDownloadStatusHidden = !setDownloadStatusHidden;
    });
}
Exemple #2
0
/** delete local problem */
void fclib_delete_local (struct fclib_local *problem)
{
  delete_matrix (problem->W);
  delete_matrix (problem->V);
  delete_matrix (problem->R);
  free (problem->mu);
  free (problem->q);
  if (problem->s) free (problem->s);
  delete_info (problem->info);
}
Exemple #3
0
/** delete global problem */
void fclib_delete_global (struct fclib_global *problem)
{
  delete_matrix (problem->M);
  delete_matrix (problem->H);
  delete_matrix (problem->G);
  free (problem->mu);
  free (problem->f);
  if (problem->b) free (problem->b);
  free (problem->w);
  delete_info (problem->info);
}
Exemple #4
0
void del_link(cache_t cache,link_t * obj){
    //deletes the thing pointed to by the obj and replaces it with the next thing in the linked list  (a NULL if it is at the end)
    link_t myobj = *obj;
    if(*obj != NULL){
        *obj = myobj->next;

        cache->mem_used -= myobj->data.val_size;
        cache->num_elements--;

        free((uint8_t*)myobj->data.key);
        free((void *)myobj->data.val);

        delete_info(cache->evic_policy,myobj->data.policy_info);

        free(myobj);
    }
}
Exemple #5
0
int main(int argc, char* argv[])
{
    //this function will search for the directories
    //open the file called nicknames.txt
    const char *where = ".\\*";
    char  input[100] = " ";
    char * pQuit = "QUIT";
    char buffer[kBufferLengh] = {0};


    int searchCount = 0;
    int hashCount = 0;
    int linkListCount = 0;

    LARGE_INTEGER startTime = {0};
    LARGE_INTEGER endTime = {0};
    LARGE_INTEGER frequency = {0};

    double hashTotalTime = 0;
    double linkedTotalTime = 0;


    FILE* pFile = NULL;
    WIN32_FIND_DATA     filedata = {0};
    HANDLE				h = FindFirstFile(where, &filedata);

    NICK_NAMES* newHead = NULL;
    LLIST *hashtable[MaxHashEntries] = {NULL};


    //open the file and check if its null
    pFile = fopen("nicknames.txt","r");

    if(pFile == NULL)
    {
        printf("Error!!! Can`t open file");
        return 0;
    }

    do
    {
        // prompt user for a first name

        fgets(buffer,kBufferLengh, pFile);

        // if it's empty, quit inputting


        // get rid of the '\n' that fgets() put in if it's there
        eliminateEndOfLine(buffer);

        /*pass in the "buffer" that contains the nickname and real name*/
        newHead = insert(buffer,newHead);
        addHashItem(hashtable,buffer);


    } while(!feof(pFile));

    /* prompt the user for input and the look quits when "QUIT" is typed also
    we call the QueryPerformanceCounter and we pass the frequency startTime and endTime
    to measure how long did each search took[linklist and hash table]*/


    printf("Please enter the name you want to search\n\n");
    while(1)
    {

        fgets(input,sizeof(input),stdin);
        eliminateEndOfLine(input);

        if(strcmp(input,pQuit)== 0)
        {
            break;

        }
        else
        {

            searchCount++;
            QueryPerformanceFrequency(&frequency);
            QueryPerformanceCounter(&startTime);

            showSearchResultsForLinkList(newHead,input,&linkListCount);

            QueryPerformanceCounter(&endTime);
            linkedTotalTime += (double)(endTime.QuadPart - startTime.QuadPart) / frequency.QuadPart;


            QueryPerformanceCounter(&startTime);

            findHashItem(hashtable,input,&hashCount);

            QueryPerformanceCounter(&endTime);
            hashTotalTime += (double)(endTime.QuadPart - startTime.QuadPart) / frequency.QuadPart;

        }

    }

    printf("=============Results=============\n\n");
    printf("The Total Number of Searches: %d\n",searchCount);
    printf("the total number of comparisons done by linked list : %i\n",linkListCount);
    printf("the total number of comparisons done by hash Table : %i\n\n",hashCount);
    printf("=============Timing Results=============\n\n");
    printf("the total time took by link list was : %0.2f miliseconds\n",linkedTotalTime * 1000);
    printf("the total time took by hash Table was : %0.2f miliseconds\n",hashTotalTime * 1000);

    //dealocate all the memory
    delete_info(newHead);
    emptyHashTable(hashtable);

    return 0;
}