Пример #1
0
void AddBetween (struct nodo ** list, struct nodo * add)
{
	struct nodo * act = NULL, * prev = NULL;
	/* this function will add the item in the linked list
	according to nodo->nclient. This function will never create the
	list, since all the functions that call this one, check if they
	have to create the list. The function can add items at the beginning,
	middle or end of the list. */
	act = *list;
	prev = *list;
	while (act && (act->nclient <= add->nclient))
	{
		prev = act;
		act = act->next;
	}
	if (! act)
		AddEnd (list, add);
	else if (prev == act)
		AddBegin (list, add);
	else
	{
		/* once again we rearrange pointers. Easy to get the idea
		if you look at the names */
		prev->next = add;
		add->next = act;
		add->prev = prev;
		act->prev = add;
	}
}
Пример #2
0
bool TUI_CustomControl::End    (TShiftState _Shift){
	switch(action){
	case etaSelect: return SelectEnd(_Shift);
	case etaAdd: 	return AddEnd(_Shift);
	case etaMove: 	return MovingEnd(_Shift);
	case etaRotate: return RotateEnd(_Shift);
	case etaScale: 	return ScaleEnd(_Shift);
    }
    return false;
}
Пример #3
0
void TSmartPacket::CreateNotify(int nType, TSSmartDoc *pDoc, void *pvoid, long nLen)
{
	if( nType == MSG_WARNING )
		Create(PACKET_CMD_WARNING, SERVER_SID);
	else if( nType == MSG_ERROR )
		Create(PACKET_CMD_ERROR, SERVER_SID);
	else
		Create(PACKET_CMD_DATA, SERVER_SID);

	if( pDoc == NULL )
		AddItem(0);
	else
		AddItem(pDoc->m_nAuthID);

	AddItem((char*)pvoid, nLen);
	AddEnd();
}
Пример #4
0
void AddClient (struct nodo ** list)
{
	/* this functions adds a new node to the linked list. The node can
	be added at the beginning, at the end or ordered by number */
	struct nodo * aux = NULL;
	char	temp[40];
	int	number, choice;
	aux = (struct nodo *) malloc (sizeof (struct nodo));
	if (aux)
	{
		/* we ask for the information about the new client */
		printf("\nNumber: "); scanf("%i", &(aux->nclient));
		printf("Name: "); scanf("%s", aux->name);
		printf("Total: "); scanf("%f", &(aux->total));
		if (! *list)
		{
			/* we are creating the list. There are neither previous
			nor nexts. So, we have to specify it by assigning NULL
			to those addresses */
			*list = aux;
			aux->next = NULL;
			aux->prev = NULL;
		}
		else
		{
			puts("\n0 - Cancel");
			puts("1 - Add at the beginning.");
			puts("2 - Add at the end.");
			puts("3 - Add ordered");
			CHOICE(choice);
			switch (choice)
			{
				case 0: free(aux); break;
				case 1: AddBegin(list, aux); break;
				case 2: AddEnd(list, aux); break;
				case 3: AddBetween(list, aux); break;
				default: break;
			}
		}
	}
	else
	{
		puts ("Memory unavailable.");
		getch();
	}
}
void main()
{
	int ch;
	Stud *head=NULL;
	clrscr();
	while(ch!=0)
	{
		 printf("\n\n\t\t1. Add End\
				   \n\t\t2. Add Mid\
				   \n\t\t3. Display\
				   \n\t\t4. Delete Beg\ \
				   \n\t\t5. Rev\
				   \n\t\t6. Sort\
				   \n\t\t0. Exit\
				   \n\t Enter Your choice ");
		 scanf("%d",&ch);
		 switch(ch)
		 {
			case 1:
				  head=AddEnd(head);
				  break;
			case 3:

				  Display(head);
				  break;
			case 2:
				 {
				   int pos;
				   printf("\n\n\t Enter The Pos ");
				   scanf("%d",&pos);
				   head=AddMid(head,pos);
				  }
				  break;
			case 4:
			head=DelBeg(head);
			break;
			case 5:
				 head=Rev(head);
				 break;
			case 6:
				 head=Sort(head);
				 break;
		 }
	}
	getch();
}
Пример #6
0
//passing by reference since multiple returns at ocne is not possible
void DealCards(cPtr& deckList, cPtr& handList, const int passingAmount)
{
	int deckSize = Length(deckList);
	cPtr hold;

	for(int i = 0; i < passingAmount; ++i)
	{
		if(deckSize > 0)
		{
			hold = Search(deckList, -1);//-1 refers to last element of list, which is the top of the deck
			deckList = RemoveN(deckList, -1);
			handList = AddEnd(handList, hold);
		}
		else
		{
			printf("ERROR: Attmepting to access cards that do not exist in parameter 1 of DealCards.\n");
		}
	}
}