Пример #1
0
Node* insertX(Node* toAdd, Node* root){
	//Checks if the x values are the same.
	if(abs(toAdd->data->x - root->data->x) <= 0.00001)
	{
		//If both the x and y values are the same, it's the same store.
		// We don't need stores in the tree twice, so return NULL.
		if(abs(toAdd->data->y - root->data->y) <= 0.00001)
			return NULL;
		//Checks the y values next, and puts the entry on the
		// left if its y is smaller...
		else if(toAdd->data->y < root->data->y)
			root->left = insertX(toAdd, root->left);
		// or on the right if its y is bigger.
		else
			root->right = insertX(toAdd, root->right);
	}
	//If the x values are different, puts the entries with x values smaller 
	// than the root's x value on the left...
	if(toAdd->data->x < root->data->x)
		root->left = insertX(toAdd, root->left);
	// and the ones with x values larger than the root's x value
	// on the right.
	else
		root->right = insertX(toAdd, root->right);

	return root;
}
Пример #2
0
 must_inline void YAddAX(TY* pY,long x0,long x1){
     insertX(&pY->xLine,x0,x1);
 }
Пример #3
0
 must_inline void insertXNext(TX* pX,long x0,long x1){
     if (pX->nextX==0)
         insertXAtBack(pX,x0,x1);
     else
         insertX(&pX->nextX,x0,x1);		
 }