dict_t dict_add(dict_t dict, word_t word, def_t def) { assert(dict != NULL && word != NULL && def != NULL && (!dict_exists(dict, word))); index_t index_word = index_from_string(word); data_t data_def = data_from_string(def); list_t new_list = list_append(dict->list, index_word, data_def); dict->list = new_list; dict->length++; return (dict); }
dict_t dict_add(dict_t dict, word_t word, def_t def) { assert(dict != NULL && word != NULL && def != NULL && !dict_exists(dict,word)); index_t index = index_from_string(word); data_t data = data_from_string(def); dict->length = dict->length +1; dict->data = list_add(dict->data,index,data); return dict; }
dict_t dict_add(dict_t dict, word_t word, def_t def) { /*Precondition verification*/ assert(dict != NULL); assert(word != NULL); assert(def != NULL); assert(!dict_exists(dict, word)); index_t index = index_from_string(word); data_t data = data_from_string(def); dict->length += 1; dict->data = bst_add(dict->data, index, data); /* POST: the elements of the result are the same as the one in 'dict' with * the new pair ('word', 'def') added.*/ return (dict); }