< eref er; < ercIter it; < < for_ercElems (er, it, c) --- > erc_elements(c, er)
< if (eref_get (er).ssNum == key) < { < erc_iterReturn (it, er); < } < } --- > if (eref_get(er).ssNum == key) return (er); > } end_erc_elements ;
< eref er; < ercIter it;
< for_ercElems (er, it, c) --- > erc_elements (c, er)
< } --- > } end_erc_elements ;
< eref er; < ercIter it;
< for_ercElems (er, it, db[i]) --- > { > erc_elements(db[i], er) > {
< erc_iterFinal (it);
> } > } end_erc_elements ;
< eref er; < ercIter it; < employee e1; < < for_ercElems (er, it, s) --- > erc_elements(s, er)
< e1 = eref_get (er); --- > employee e1 = eref_get(er);
< erc_iterReturn (it, er); < } --- > return er; > } end_erc_elements ;
< ercIter it; < eref er;
< /*@-mods@*/ < for_ercElems (er, it, s2) < empset_insertUnique (result, eref_get (er)); < /*@=mods@*/
> empset_elements(s2, emp) > { > empset_insertUnique(result, emp); > } end_empset_elements ; >
< eref er; < ercIter it;
< /*@-mods@*/ < for_ercElems (er, it, s1) < if (!empset_member (eref_get (er), s2)) < erc_insert (result, er); < /*@=mods@*/ --- > empset_elements (s1, emp) > { > if (!empset_member(emp, s2)) > empset_insert(result, emp); > } end_empset_elements ;
< eref er; < ercIter it; < erc toDelete; --- > erc toDelete = erc_create();
< toDelete = erc_create (); --- > empset_elements (s2, emp) > { > if (!empset_member(emp, s2)) > empset_insert(toDelete, emp); > } end_empset_elements ;
< for_ercElems (er, it, s1) < if (!empset_member (eref_get (er), s2)) < erc_insert (toDelete, er); --- > empset_elements (toDelete, emp) > { > empset_delete(s1, emp); > } end_empset_elements;
< for_ercElems (er, it, toDelete) < erc_delete (s1, er); <
< eref er; < ercIter it; < < /*@-mods@*/ < for_ercElems (er, it, s1) < if (!empset_member (eref_get (er), s2)) < erc_iterReturn (it, FALSE); < /*@=mods@*/ --- > empset_elements(s1, emp) > { > if (!empset_member(emp, s2)) return FALSE; > } end_empset_elements ;
> #define empset_elements(e, m_x) \ > erc_elements(e, m_y) { employee m_x = eref_get(m_y); > #define end_empset_elements } end_erc_elements >
> > iter empset_elements (empset s, yield employee x); >
< ercIter erc_iterStart (erc c) < { < ercIter result; < < result = (ercIter) malloc (sizeof (ercList)); < < if (result == 0) < { < printf ("Malloc returned null in erc_iterStart\n"); < exit (1); < } < < *result = c->vals; < return result; < } < < eref erc_yield (ercIter it) < { < eref result; < < if (*it == 0) < { < return erefNIL; < free (it); < } < < result = (*it)->val; < *(it) = (*it)->next; < return result; < } <
< eref er; < ercIter it;
< /*@-mods@*/ < for_ercElems (er, it, c) --- > erc_elements(c, er)
< } < /*@=mods@*/ --- > } end_erc_elements;
< typedef ercList *ercIter;
< # define erc_iterFinal(it) (free(it)) --- > # define erc_elements(c, m_x) \ > { erc m_c = (c); ercElem *m_ec = (m_c)->vals; int m_i = 0; \ > while (m_i < (m_c)->size) { \ > eref m_x = m_ec->val; m_ec = m_ec->next; m_i++;
< # define erc_iterReturn(it, result) \ < do { erc_iterFinal(it); return result; } while (0) < < # define for_ercElems(er, it, c)\ < for (er = erc_yield (it = erc_iterStart (c)); \ < !eref_equal (er, erefNIL); \ < er = erc_yield (it)) --- > # define end_erc_elements }}
< mutable type ercIter;
< ercIter erc_iterStart(erc c) < { < modifies c; < /* ensures fresh(result) /\ result' = [c^.val, c] < /\ c' = startIter(c^); < */ < } < < eref erc_yield(ercIter it) < { < modifies it; /* , it^.eObj */ < /* ensures if it^.toYield \neq { } < then yielded(result, it^, it') < /\ (it^.eObj)' = (it^.eObj)^ < else result = erefNIL /\ trashed(it) < /\ (it^.eObj)' = endIter((it^.eObj)^); < */ < } < < void erc_iterFinal(ercIter it) < { < modifies it; /* , it^.eObj; */ < /* ensures trashed(it) < /\ (it^.eObj)' = endIter((it^.eObj)^); < */ < } <
> > iter erc_elements (erc c, yield eref el);
< eref er;
< ercIter it;
< /*@-mods@*/ < for_ercElems (er, it, t) --- > ereftab_elements(t, er)
< if (employee_equal (&e, &e1)) < { < erc_iterReturn (it, er); < } < } < /*@=mods@*/ < --- > if (employee_equal(&e, &e1)) return er; > } end_ereftab_elements ;
> # define ereftab_elements(s, m_x) erc_elements(s, m_x) > # define end_ereftab_elements end_erc_elements >
> > iter ereftab_elements(ereftab s, yield eref x); > >