예제 #1
0
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
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;
}