//############################################################################## //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //############################################################################## void xHashMap::put(xObject* key, xObject* value) throw(xClassCastException) { int index = indexOf(hash(key)); (*m_table)[index] = addInList(value,key,(*m_table)[index]); if((m_table->size() * m_loadFactor) < m_count) rehash(); }
struct s_list<T>& addInListAtPos(struct s_list<T>*& begin, const T& data, int pos) { struct s_list<T> *save = begin; struct s_list<T> *elem = new s_list<T>(data); int i = 0; if (begin == NULL || pos <= 0) return addInList(begin, data); while (i != (pos - 1) && begin->next != NULL) { begin = begin->next; i++; } elem->next = begin->next; begin->next = elem; begin = save; return *elem; }
int main() { #ifndef ONLINE_JUDGE freopen("input_dsa.txt" , "r" , stdin) ; #endif int vertices = 0 ; scanf("%d",&vertices) ; graph* g = newgraph(vertices) ; int edges = 0 , i; scanf("%d",&edges) ; int v1 , v2 ; for(i = 0 ; i < edges ; ++i) { scanf("%d%d",&v1,&v2) ; addInList(g->adjlist[v1] , g->v[v2]) ;// considering directed graph } dfs(g) ; return 0; }
int main() { /* test de la liste */ pthread_t th_test1 = 14862153215624521; /*pthread_t th_test2; pthread_t th_test3; pthread_t th_test4;*/ Liste testList = creatList(); printf("liste vide creee\n"); if(isEmpty(testList)) printf("la liste est bien vide\n"); else { printf("erreur liste non vide !\n") ; exit(99); } testList = addInList(testList, th_test1); printf("ajout d'un element dans la liste\n"); mapList(testList); testList = removeFromList(testList, th_test1); if(isEmpty(testList)) printf("la liste est bien vide\n"); else { printf("erreur liste non vide !\n") ; exit(99); } destroyList(testList); /*Fin des test de la liste*/ return 0; }