1: #include "../h/rt.h" 2: #ifdef SETS 3: /* 4: * delete(S,x) - delete element x from set S if it is there 5: * (always succeeds and returns S). 6: */ 7: 8: Xdelete(nargs,arg2,arg1,arg0) 9: int nargs; 10: struct descrip arg0, arg1, arg2; 11: { 12: register struct descrip *pd; 13: int res ; 14: extern struct descrip *memb(); 15: 16: DeRef(arg1) 17: DeRef(arg2) 18: arg0 = arg1; 19: 20: if (QUAL(arg1) || TYPE(arg1) != T_SET) 21: runerr(119,&arg1); 22: /* 23: * The technique and philosophy here are the same 24: * as used in insert.c - see comment there. 25: */ 26: pd = memb(BLKLOC(arg1),&arg2,hash(&arg2),&res); 27: if (res == 1) { 28: /* 29: * The element is there so delete it. 30: */ 31: *pd = BLKLOC(*pd)->selem.sblink; 32: (BLKLOC(arg1)->set.setsize)--; 33: } 34: } 35: 36: Procblock(delete,2) 37: 38: #else SETS 39: char junk; /* prevent null object file */ 40: #endif SETS