Example #1
0
int main()
{
    List* L;
    List* Hash[101];
    for(int i=0; i<101; i++)
    {
        Hash[i]=(List*) calloc (1, sizeof(List));
        list_ctor(Hash[i]);
    }
    L=(List*) calloc (1, sizeof(List));
    list_ctor(L);
    FILE* F;
    F=fopen("1.txt","r");
    assert(F);
    while(!feof(F))
    {
        readfromfile(F,L);
    }



    hasher(L,Hash,4);



    for (int i=0; i<101; i++)printf("i=%5d  %d\n",i,Hash[i]->amount);


}
Example #2
0
int		zt_build_command(t_list *pckts, char **cmd)
{
  t_list	frags;
  char		*frag;
  bool		failure;

  failure = false;
  list_ctor(&frags, &free);
  while (!failure && (frag = list_pop(pckts)))
    {
      if (strchr(frag, '\n'))
	{
	  if (split(pckts, &frags, frag) == RET_FAILURE ||
	      build(&frags, cmd) == RET_FAILURE)
	    failure = true;
	  break;
	}
      else if (list_enqueue(&frags, frag) == RET_FAILURE)
	failure = true;
    }
  while ((frag = list_dequeue(&frags)))
    list_push(pckts, frag);
  list_dtor(&frags);
  return (failure ? RET_FAILURE : RET_SUCCESS);
}
Example #3
0
int main()
{
    list* List = list_ctor();
    list_dump(List);
    el_add(List, List -> head, 5);
    list_dump(List);
    el_add(List, List -> head, 5);
    list_dump(List);
    el_add(List, List -> head, 5);
    list_dump(List);
    el_add(List, List -> head, 5);
    list_dump(List);
    el_add(List, List -> head, 5);
    list_dump(List);
}