コード例 #1
0
ファイル: main.cpp プロジェクト: janfranco27/TPA-Projects
void* crearNodo(void* address, int size)
{
    char* block = (char *)malloc(size);
    memcpy(block, address, size);

    garbageCollector.insert(block,size);
    return block;
}
コード例 #2
0
int main(){

    BinomialHeap<int> H;
    H.insert(0);
    H.insert(1);
    H.print();

    return 0;
}
コード例 #3
0
ファイル: binomialheap.cpp プロジェクト: Varitas35/algorithms
int main()
{
    cout<<"Binomial Heap\n\n";
    BinomialHeap bh;
    char ch;
    int val;
        /*  Perform BinomialHeap operations  */
    do
    {
        cout<<"1. Insert "<<endl;
        cout<<"2. Delete "<<endl;
        cout<<"3. Size"<<endl;
        cout<<"4. Check empty"<<endl;
        cout<<"5. Clear"<<endl;
        int choice;
        cout<<"Enter your Choice: ";
        cin>>choice;
        switch (choice)
        {
        case 1 :
            cout<<"Enter integer element to insert: ";
            cin>>val;
            bh.insert(val);
            break;
        case 2 :
            cout<<"Enter element to delete: ";
            cin>>val;
            bh.Delete(val);
            break;
        case 3 :
            cout<<"Size = "<<bh.getSize()<<endl;
            break;
        case 4 :
            cout<<"Empty status = ";
            if (bh.isEmpty())
                cout<<"Heap is empty"<<endl;
            else
                cout<<"Heap is non - empty"<<endl;
            break;
        case 5 :
            bh.makeEmpty();
            cout<<"Heap Cleared\n";
            break;
        default :
            cout<<"Wrong Entry \n ";
            break;
        }

        /* Display heap */
        bh.displayHeap();
        cout<<"\nDo you want to continue (Type y or n) \n";
        cin>>ch;
    }
    while (ch == 'Y'|| ch == 'y');
    return 0;
}