Beispiel #1
0
void WMHashRemove(WMHashTable * table, const void *key)
{
	unsigned h;

	h = HASH(table, key);

	table->table[h] = deleteFromList(table, table->table[h], key);
}
Beispiel #2
0
List* cmdUnassign(List* env, cmdLine* line) {
    if (line->argCount != 2) {
        perror("'unassign' should have only one arguments\n");
    }
    else {
        env= deleteFromList(env, line->arguments[1]);
    }
    return env;
}
int main(void)
{
    struct node *ptr = NULL;
    createList(7);
    addNode(8);
    addNode(9);
    addNode(10);
    addNode(11);
    printList();
    deleteFromList(10);
    printList();
}
Beispiel #4
0
void minimumSpanningTreePrim(struct gnode *adj[],int num){
    typedef enum { UNSEEN, INTREE, NEAR } stat;
    int parent[MAX],status[MAX]={UNSEEN}, nearWt[MAX];
    int stuck, current, edgeCount, minWt, ver, wt, w;
    struct gnode *ptr, *nearList, *ptr2;
    current=0;
    stuck=0;
    status[current]=INTREE;
    edgeCount=0;
    while((edgeCount<=num-1)&&!stuck){
        ptr=adj[current];
        while(ptr!=NULL){
            ver=ptr->vertex;
            wt=ptr->weight;
            if((status[ver]==NEAR) && (wt<nearWt[ver])){
                parent[ver]=current;
                nearWt[ver]=wt;
            }
            else if(status[ver]==UNSEEN){
                status[ver]=NEAR;
                parent[ver]=current;
                insertBeg(nearList,ver);
            }
            ptr=ptr->next;
        }
        if(nearList==NULL){
            stuck=1;    //true;
        }
        else{
            current=nearList->vertex;
            minWt=nearWt[current];
            ptr2=nearList->next;
            while(ptr2!=NULL){
                w=ptr2->vertex;
                if(nearWt[w]<minWt){
                    current=w;
                    minWt=nearWt[w];
                }
                ptr2=ptr2->next;
            }
            //deletelist();     //TODO
            deleteFromList(nearList,current);
            status[current]=INTREE;
            edgeCount+=1;
        }
    }
    for(current=1;current<num;current++){
        printf("(%d,%d)",current,parent[current]);
    }
}
int testInsertDelete()
{
    FILE *fin = fopen("/Users/sunpeifeng/Desktop/SourceTree/DataStructures@YWM/DataStructures@YWM/SqListSource", "r");
    SqList sqlist = setupLinearListUsingFile(fin);
    int e = 9999;
    deleteFromList(&sqlist, 1, &e);
    ElemType *a = traverseList(sqlist);
    printf("%d",*a);
//        fclose(fin);

    rewind(fin);
    compareListWithGivenResultFile(sqlist, fin);
    return OK;
}
Beispiel #6
0
static HashItem *deleteFromList(HashTable * table, HashItem * item, const void *key)
{
	HashItem *next;

	if (item == NULL)
		return NULL;

	if ((table->callbacks.keyIsEqual && (*table->callbacks.keyIsEqual) (key, item->key))
	    || (!table->callbacks.keyIsEqual && key == item->key)) {

		next = item->next;
		RELKEY(table, item->key);
		wfree(item);

		table->itemCount--;

		return next;
	}

	item->next = deleteFromList(table, item->next, key);

	return item;
}
Beispiel #7
0
void unloadInputPlugin(InputPlugin * inputPlugin) {
	if(inputPlugin->finishFunc) inputPlugin->finishFunc();
	deleteFromList(inputPlugin_list, inputPlugin->name);
}
Beispiel #8
0
void scanDelete(struct dbCommon *precord)
{
    short scan;

    /* get the list on which this record belongs */
    scan = precord->scan;
    if (scan == menuScanPassive) return;
    if (scan < 0 || scan >= nPeriodic + SCAN_1ST_PERIODIC) {
        recGblRecordError(-1, (void *)precord,
            "scanDelete detected illegal SCAN value");
    } else if (scan == menuScanEvent) {
        char* eventname;
        int prio;
        event_list *pel;
        scan_list *psl = 0;

        eventname = precord->evnt;
        prio = precord->prio;
        if (prio < 0 || prio >= NUM_CALLBACK_PRIORITIES) {
            recGblRecordError(-1, (void *)precord,
                "scanDelete detected illegal PRIO field");
            return;
        }
        do /* multithreading: make sure pel is consistent */
            pel = pevent_list[0];
        while (pel != pevent_list[0]);
        for (; pel; pel=pel->next) {
            if (strcmp(pel->event_name, eventname) == 0) break;
        }
        if (pel && (psl = &pel->scan_list[prio]))
            deleteFromList(precord, psl);
    } else if (scan == menuScanI_O_Intr) {
        ioscan_head *piosh = NULL;
        int prio;
        DEVSUPFUN get_ioint_info;

        if (precord->dset==NULL) {
            recGblRecordError(-1, (void *)precord,
                "scanDelete: I/O Intr not valid (no DSET)");
            return;
        }
        get_ioint_info=precord->dset->get_ioint_info;
        if (get_ioint_info == NULL) {
            recGblRecordError(-1, (void *)precord,
                "scanDelete: I/O Intr not valid (no get_ioint_info)");
            return;
        }
        if (get_ioint_info(1, precord, &piosh)) return;
        if (piosh == NULL) {
            recGblRecordError(-1, (void *)precord,
                "scanDelete: I/O Intr not valid");
            return;
        }
        prio = precord->prio;
        if (prio < 0 || prio >= NUM_CALLBACK_PRIORITIES) {
            recGblRecordError(-1, (void *)precord,
                "scanDelete: get_ioint_info returned illegal priority");
            return;
        }
        deleteFromList(precord, &piosh->iosl[prio].scan_list);
    } else if (scan >= SCAN_1ST_PERIODIC) {
        deleteFromList(precord, &papPeriodic[scan - SCAN_1ST_PERIODIC]->scan_list);
    }
    return;
}