REPETITION(2) Demeter Software REPETITION(2) NAME Repetition - methods attached to class repetition DESCRPTION Summary of methods attached to class _R_e_p_e_t_i_t_i_o_n. The inter- faces are given in terms of type ent which is personalized by macros. typedef void* ent; typedef int(*PFC) (ent a,ent b); int insert(ent a); Inserts _a at the beginning of the list. int append(ent a); Appends _a at the end of the list. int list_length(); Returns the number of entries in the list. int empty() Returns 0 if list is empty and non-zero otherwise. ent get(); Gets first element from list and removes it. ent car(); Gets first element of list without removing it. int member(ent a,PFC f); Tests whether _a is an element of list, using _f as test function. _f should be a function taking two list elements as arguments and returning an int. member returns 0 if _a is not in the list, other- wise, member returns the position at which _a appears in the list, relative to 1 (i.e., if _a is the first element, member returns 1). NonEmptyList* remove(ent a,PFC f); Removes all elements of the list that pass the test in _f, as compared with _a. _f should be a func- tion taking two list elements as arguments and returning an int. _r_e_m_o_v_e returns a list that con- tains every element in the current list except for those for which _f becomes true. That is, _r_e_m_o_v_e has a lisp-like behavior. NonEmptyList* lisp_append(NonEmptyList* p); Returns a new list that results from concatenating the receiver of the message with the list _p. Demeter Last change: 13 May 1991 1 REPETITION(2) Demeter Software REPETITION(2) void concatenate( repetition* lst ); Destructively appends _l_s_t to the end of the receiver list. The original list is contained in the result. ent n_th(int a); Returns the _a th element of the list. n_th is 1- based, i.e., the first element has number 1. ent lastexp(); Returns the last element in list without removing it. Returns 0 if list is empty. repetition(); Constructor. The actual name used is given by the class of the desired list object. repetition(ent a); Nonempty lists can also be constructed. repetition_iterator(repetition &s); Associates an iterator object to a list. ent operator()(); The operator () applied to an iterator object returns the next element in the list to which the iterator is associated. Demeter Last change: 13 May 1991 2