Example #1
0
	inline void Adjust(long t) {
		long l1 = Succ(root, t);
		while (true) {
			if (l1 == inf) break;
			long l2 = Succ(root, l1);
			if (l2 == inf) break;
			if (Cross(t, l1, l2) >= 0)
				Delete(l1);
			else break;
			l1 = l2;
		}
		
		l1 = Prev(root, t);
		while (true) {
			if (l1 == inf) break;
			long l2 = Prev(root, l1);
			if (l2 == inf) {
				if (S[t].y > S[l1].y) {
					Delete(l1);
				}
				break;
			}
			if (Cross(l2, l1, t) >= 0 || S[t].y > S[l1].y)
				Delete(l1);
			else break;
			l1 = l2;
		}
	}
Example #2
0
// 通过a的之后邻居来找b的第一个邻居的num号
PointNumero DocRecord::Successor(PointNumero a, PointNumero b)
{
	DListPeek p = points[a].adjacent;
	if(p == NULL)
		return -1;

	do {
		if(p->point_num == b)
			return Succ(p)->point_num;
		p = Succ(p);
	} while(p != points[a].adjacent);

	return -1;
}
Example #3
0
File: 81.c Project: zyxstar/md_note
void Collect(SLList *L,int i,ArrType f,ArrType e)         /*Collect() function */
{  int j,t; 
   for(j=0;!f[j];j=Succ(j));                              /*Succ()*/
   L->r[0].next=f[j];
   t=e[j];
   while(j<RD-1)                                          
   {  for(j=Succ(j);j<RD-1&&!f[j];j=Succ(j));             
      if(f[j])
      {  L->r[t].next=f[j];
         t=e[j];
      }/*end of if*/
   }/*end of while */
   L->r[t].next=0;
   OutExample(L,i);                                      /*Add Output Example function here  */
}/*end of Collect() function */
Example #4
0
void Dequeue(Queue Q) {
	if (IsEmpty(Q))
		Error( "Empty queue" );
	else {
		Q->Size--;
		Q->Front = Succ(Q->Front, Q);
	}
}
Example #5
0
File: queue.c Project: 4179e1/misc
void Dequeue (Queue Q) {
	if (IsEmpty (Q))
	{
		fprintf (stderr, "ERROR: empty queue\n");
		exit (1);
	} else {
		Q->Size--;
		Q->Front = Succ (Q->Front, Q);
	}
}
Example #6
0
	inline void Add(double xi, double yi) {
		Insert(0, root, xi, yi);
		long temp = root;
		long l1 = Prev(root, temp), l2 = Succ(root, temp);
		if ( (l2 != inf) && ( ((l1 != inf) && Cross(l1, temp, l2) >= 0) || S[l2].y > S[temp].y)) {
			Delete(temp);
			return;
		}
		Adjust(temp);
	}
Example #7
0
void Dequeue(QueueRecord* Q) {

	if (IsEmpty(Q)) {
		return;
	} else {
		Q->Size--;
		Q->Front = Succ(Q->Front);
	}

}
Example #8
0
void Dequeue(Queue Q) {

  if (IsEmpty(Q)) {
    Error("Dequeue Error: The queue is empty.");
  } else {
    Q->Size--;
    Q->Front = Succ(Q->Front, Q);
  }

}
Example #9
0
void Dequeue(Queue Q) {

  if (IsEmptyQueue(Q)) {
    return;
  } else {
    Q->Size--;
    Q->Front = Succ(Q->Front, Q);
  }

}
Example #10
0
		inline void Delete(int v) {
			Node* t = Select(root, v);
			if (t == null) {
				t = GetMin(root);
				Splay(t, null);
				t->ch[1]->p = null; root = t->ch[1];
				return;
			}
			Node* now = Succ(t);
			Node* L = Prev(now), *R = Succ(now);
			Splay(now, null);
			if (L == null || R == null) {
				bool d = (R != null);
				root = now->ch[d], root->p = null;
				return;
			}
			Splay(L, root); Splay(R, root);
			L->Set(R, 1);
			L->Update(); L->p = null;
		}
Example #11
0
File: queue.c Project: 4179e1/misc
void Enqueue (QueueElementType X, Queue Q) {
	if (IsFull (Q))
	{
		fprintf (stderr, "ERROR: Full queue\n");
		exit (1);
	} else {
		Q->Size++;
		Q->Rear = Succ (Q->Rear, Q);
		Q->Array[Q->Rear] = X;
	}
}
Example #12
0
void Enqueue(ElementType X, Queue Q)
{
    if(IsFull(Q))
        Error("Full Queue");
    else
    {
        Q->Size++;
        Q->Rear = Succ(Q->Rear, Q);
        Q->Array[Q->Rear] = X;
    }
}
Example #13
0
/*If the queue is full then evict the front (the first was enqueued) */
void Enqueue(DTNMsg X, QueueRecord* Q) {

	if (IsFull(Q)) {
		Dequeue(Q);
	} else {
		Q->Size++;
		Q->Rear = Succ(Q->Rear);
		Q->Array[Q->Rear] = X;
	}

}
Example #14
0
void Enqueue(ElementQueueType X, Queue Q) {

  if (IsFull(Q)) {
    return;
  } else {
    Q->Size++;
    Q->Rear = Succ(Q->Rear, Q);
    Q->Array[Q->Rear] = X;
  }

}
Example #15
0
void Enqueue(ElementType X, Queue Q) {

  if (IsFull(Q)) {
    Error("Enqueue Error: The queue is full.");
  } else {
    Q->Size++;
    Q->Rear = Succ(Q->Rear, Q);
    Q->Array[Q->Rear] = X;
  }

}
Example #16
0
int Enqueue(ElementType X, Queue Q) {
	if (IsFull(Q)) {
		Error( "Full queue" );
		return (0);
	} else {
		Q->Size++;
		Q->Rear = Succ(Q->Rear, Q);
		Q->Array[Q->Rear] = X;
		return (1);
	}
}
Example #17
0
void Enqueue(ElementType X, Queue Q)
{
	if(IsFull(Q))
		Error("Full Queue");
	else
	{
		Q->Size++;
		Q->Rear = Succ(Q->Rear,Q);//用于对Rear进行操作包括+1和循环操作
		Q->Arrary[Q->Rear] = X;
	}
}
Example #18
0
int test_Succ()	{
	
	solved=TRUE;
	Succ(&TEMPLIST);
	if (!solved)	{
		printf("Operace Succ nebyla implementována!\n");
		return(FALSE);
	}
	print_elements_of_list(TEMPLIST);
	return(TRUE);
	
}
Example #19
0
int DocRecord::DListDelete(DListPeek *dlist, PointNumero oldPoint)
{
	DListPeek p;

	if(*dlist == NULL)
		return 0;
	if(Succ(*dlist) == *dlist) {
		if((*dlist)->point_num == oldPoint) {
			delete *dlist;
			*dlist = NULL;
			return 1;
		}
		else
			return 0;
	}
	p = *dlist;
	do {
		if(p->point_num == oldPoint) {
			Succ(Pred(p)) = Succ(p);
			Pred(Succ(p)) = Pred(p);
			if(p == *dlist) {
				*dlist = Succ(p);
			}
			delete p;
			return 1;
		}
		p = Succ(p);
	} while(p != *dlist);

	return 0;
}
Example #20
0
void Dequeue(Queue Q)
{
	if(IsEmpty(Q))
	{
		printf("queue is empty!\n");
		return ;
	}
	else
	{
		Q->Sizes--;
		Q->Front=Succ(Q->Front,Q);
	}
}
Example #21
0
void SortQueue(QueueRecord* Q){
	if(IsEmpty(Q))
		return;
	DTNMsg temp;
	uint8_t i,j;

	for(i=Q->Front;i!=Q->Rear;i=Succ(i))
	{
		j=Succ(i);
		while(1){
			if((Q->Array[j]).prop > (Q->Array[i]).prop)
			{
				temp = Q->Array[i];
				Q->Array[i]=Q->Array[j];
				Q->Array[j]=temp;
			}
			if(j==Q->Rear)
				break;
			j=Succ(j);
		}
	}
}
ElementType Dequeue(Queue Q)
{
  if (IsEmpty(Q))
  {
    fprintf(stderr, "Empty Queue\n");
    exit(1);
  }

  int Index;
  Index = Q -> Front;
  Q -> Front = Succ(Q, Q -> Front);
  return Q -> Next[Index];
}
Example #23
0
void PrintQueue(QueueRecord* Q) {

int i = Q->Front;
printf("\n");
if (IsEmpty(Q))
printf("Empty Queue...\n");
else while(1){
	printf(" %d ",Q->Array[i].prob);
	if(i == Q->Rear)
		break;
	i=Succ(i,Q);
	}
printf("\n");  
}
Example #24
0
void Enqueue(int X,Queue Q)
{
	if(IsFull(Q))
	{
		printf("%s\n","Full Queue!");
		return;
	}
	else
	{
		Q->Sizes++;
		Q->Rear=Succ(Q->Rear,Q);
		Q->Array[Q->Rear]=X;
	}
}
Example #25
0
	inline double Ask(double ai, double bi) {
		double k = -ai/bi;
		long t = root;
		while (true) {
			long l1 = Prev(root, t), l2 = Succ(root, t);
			double k1 = inf, k2 = -inf;
			if (l1 != inf) k1 = Slope(l1, t);
			if (l2 != inf) k2 = Slope(l2, t);
			if (k <= k1 && k >= k2) break;
			if (k2 > k) t = S[t].r;
				else if (k1 < k) t = S[t].l;
			}
			return ai * S[t].x + bi * S[t].y;
	}
Example #26
0
ElementQueueType FrontAndDequeue(Queue Q) {

  ElementQueueType X = 0;

  if (IsEmptyQueue(Q)) {
    return X;
  } else {
    Q->Size--;
    X = Q->Array[Q->Front];
    Q->Front = Succ(Q->Front, Q);
  }
  return X;

}
Example #27
0
ElementType FrontAndDequeue(Queue Q) {

  ElementType X = 0;

  if (IsEmpty(Q)) {
    Error("FrontAndDequeue Error: The queue is empty.");
  } else {
    Q->Size--;
    X = Q->Array[Q->Front];
    Q->Front = Succ(Q->Front, Q);
  }
  return X;

}
Example #28
0
File: queue.c Project: 4179e1/misc
QueueElementType FrontAndDequeue (Queue Q) {
	QueueElementType tmp;

	if (IsEmpty (Q))
	{
		fprintf (stderr, "ERROR: empty queue\n");
		exit (1);
	} else {
		tmp = Q->Array[Q->Front];
		Q->Size--;
		Q->Front = Succ (Q->Front, Q);
	}
	return tmp;
}
Example #29
0
        ElementType
        FrontAndDequeue( Queue Q )
        {
            ElementType X = 0;

            if( IsEmpty( Q ) )
                Error( "Empty queue" );
            else
            {
                Q->Size--;
                X = Q->Array[ Q->Front ];
                Q->Front = Succ( Q->Front, Q );
            }
            return X;
        }
Example #30
0
DTNMsg FrontAndDequeue(QueueRecord* Q) {

	DTNMsg temp = {0,0,0,0,0,0,0};

	if (IsEmpty(Q))
		return temp;

	else {
		Q->Size--;
		temp = Q->Array[Q->Front];
		Q->Front = Succ(Q->Front);
	}
	return temp;

}