scalar KasmiMassonHill::calcHeight(scalar dist, scalar xi0, scalar xi1) const{

	// equal:
	if(xi0 == xi1) return zofxi(xi0);

	// calc x values at boundaries:
	scalar x0 = xofxi(xi0);
	scalar x1 = xofxi(xi1);

	// if close enough, return mean height:
	scalar d0 = mag(x0 - dist);
	scalar d1 = mag(x1 - dist);

	if(d0 <= resolution() && d1 <= resolution()){

		// calc heights
		scalar z0 = zofxi(xi0);
		scalar z1 = zofxi(xi1);

		return d1 / (d0 + d1) * z0 + d0 / (d0 + d1) * z1;

	}

	// calc middle xi and x there:
	scalar xi = 0.5 * (xi0 + xi1);
	scalar x  = xofxi(xi);

	// call again:
	if(x <= dist) return calcHeight(dist,xi,xi1);
	return calcHeight(dist,xi0,xi);

}
Exemplo n.º 2
0
/* Returns Vec4f = normal & heigh at (x,z) */
Vec4f calcSineValue(float x, float z) {
	float mag;
	Vec4f v;
	float t = animationTime;
	
	/* Sum heights of both waves at (x,z) */
	v.w = calcHeight(&sineWaveX, x, t) + calcHeight(&sineWaveZ, z, t);
	
	/* Normal for each sine wave */
	Vec2f normX = calcNormal(&sineWaveX, x, t);
	Vec2f normZ = calcNormal(&sineWaveZ, z, t);
	
	/* Combining normals */
	v.x = normX.x;
	v.y = 1.0f;
	v.z = normZ.x;
	
	/* Normalizing */
	mag = sqrt((v.x*v.x) + (v.y*v.y) + (v.z*v.z));
	v.x = v.x/mag;
	v.y = v.y/mag;
	v.z = v.z/mag;
	
	return v;
}
Exemplo n.º 3
0
 int calcHeight(TreeNode* p) {
     if (p==NULL) return 0;
     
     if (p->left==NULL) return calcHeight(p->right)+1;
     else if (p->right==NULL) return calcHeight(p->left)+1;
     else return min(calcHeight(p->left), calcHeight(p->right))+1;
 }
Exemplo n.º 4
0
LRESULT OptionsCanvas::doSize(
	WPARAM /*sizeType*/,
	int newWidth,
	int /*newHeight*/)
{
	int optimalWidth = 0;
	// Pass 1: calculate the appropriate value for optimalWidth, the needed
	// widht for the widest float/long option.
	calcHeight(newWidth, optimalWidth, false);
	// Pass 2: update the locations of all of the controls.
	calcHeight(newWidth, optimalWidth, true);
	return 0;
}
Exemplo n.º 5
0
void RenderSVGRoot::layout()
{
    ASSERT(needsLayout());

    // Arbitrary affine transforms are incompatible with LayoutState.
    view()->disableLayoutState();

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && selfNeedsLayout());

    int oldWidth = width();
    calcWidth();

    int oldHeight = height();
    calcHeight();

    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    setWidth(static_cast<int>(width() * svg->currentScale()));
    setHeight(static_cast<int>(height() * svg->currentScale()));
    calcViewport();

    // RenderSVGRoot needs to take special care to propagate window size changes to the children,
    // if the outermost <svg> is using relative x/y/width/height values. Hence the additonal parameters.
    layoutChildren(this, selfNeedsLayout() || (svg->hasRelativeValues() && (width() != oldWidth || height() != oldHeight)));
    repainter.repaintAfterLayout();

    view()->enableLayoutState();
    setNeedsLayout(false);
}
Exemplo n.º 6
0
void RenderSVGImage::layout()
{
    ASSERT(needsLayout());

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
    SVGImageElement* image = static_cast<SVGImageElement*>(node());

    if (m_needsTransformUpdate) {
        m_localTransform = image->animatedLocalTransform();
        m_needsTransformUpdate = false;
    }

    // minimum height
    setHeight(errorOccurred() ? intrinsicSize().height() : 0);

    calcWidth();
    calcHeight();

    m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image));
    m_cachedLocalRepaintRect = FloatRect();

    repainter.repaintAfterLayout();
    
    setNeedsLayout(false);
}
int main(void)
{
    initializeTree();
    while(1)
    {
        printf("1. Insert item. 2. Delete item. 3. Search item. \n");
        printf("4. Print height of tree. 5. Print height of an item. \n");
        printf("6. PrintInOrder. 7. Range Search.\n");

        int ch;
        scanf("%d",&ch);
        if(ch==1)
        {
            int item;
            scanf("%d", &item);
            insertItem(root, item);
        }
        else if(ch==2)
        {
            int item;
            scanf("%d", &item);
            deleteItem(root, item);
        }
        else if(ch==3)
        {
            int item;
            scanf("%d", &item);
            struct treeNode * res = searchItem(root, item);
            if(res!=0) printf("Found.\n");
            else printf("Not found.\n");
        }
        else if(ch==4)
        {
            int height = calcNodeHeight(root);
            printf("Height of tree = %d\n", height);
        }
        else if(ch==5)
        {
            int item;
            scanf("%d", &item);
            int height = calcHeight(item);
            printf("Height of %d = %d\n", item, height);
        }
        else if(ch==6)
        {
            int h = calcNodeHeight(root);
            printf("\n--------------------------------\n");
            printInOrder(root, h);
            printf("--------------------------------\n");
        }
        else if(ch==7)
        {
            int l,r;
            scanf("%d%d",&l,&r);
            printf("%d\n",rangeSearch(root,l,r));
        }
    }

}
Exemplo n.º 8
0
int MySBBST<Elem, Key, EEComp, KEComp>::calcHeight(MySBBSTNode *&sr)
{

    if (sr -> lc && sr -> rc)
        sr -> height = max(calcHeight(sr -> lc), calcHeight(sr -> rc)) + 1;
    else if (sr -> lc)
        sr -> height = calcHeight(sr -> lc) + 1; 
    else if (sr -> rc)
    {
        sr -> height = calcHeight(sr -> rc) + 1; 
    }
    else
    {
        sr -> height = 0;
    }

    return sr -> height;
}
void KasmiMassonHill::calcAll(){

	// init and fill height list:
	heightTable_ = HashTable<scalar>( a_ / resolution() + 1);
	for(label i = 0; i < heightTable_.size(); i++){
		scalar d = i * resolution();
		heightTable_.set(hkey(d), calcHeight(d, 0., a_));
	}

}
int main(void)
{
	unsigned int i;
	int sum = 0;
	int current = 0;
	int hgt_percent = 0;
	int degrees = 0;

	STATE = IDLE;


	initClock();
	initADC();
	initYaw();
	initMotorPin();
	initDisplay();
	intButton();
	initConsole();
	initPWMchan();
	initCircBuf (&g_inBuffer, BUF_SIZE);


	// Enable interrupts to the processor.
	IntMasterEnable();

	while (1)
	{
		//double dt = SysCtlClockGet() / SYSTICK_RATE_HZ;
		degrees = yawToDeg();


		// Background task: calculate the (approximate) mean of the values in the
		// circular buffer and display it.
		sum = 0;
		for (i = 0; i < BUF_SIZE; i++) {
			current = readCircBuf (&g_inBuffer);
			sum = sum + current;

		}
		int newHght = ADC_TO_MILLIS(sum/BUF_SIZE);
		if(initialRead != 0)
		{
			hgt_percent = calcHeight(initialRead, newHght);

		}
		if (STATE == FLYING || STATE == LANDING){
			PIDControl(hgt_percent, SysCtlClockGet() / SYSTICK_RATE_HZ);
			PWMPulseWidthSet (PWM_BASE, PWM_OUT_1, period * main_duty / 100);
			PWMPulseWidthSet (PWM_BASE, PWM_OUT_4, period * tail_duty / 100);
		}

		displayInfo((int)initialRead, hgt_percent, degrees);
	}
}
Exemplo n.º 11
0
Elem MySBBST<Elem, Key, EEComp, KEComp>::remove(Key k)
{
    Elem e = zero;
    if (k && root)
    {
        e = remove(root, k);
        calcHeight(root);
    }

    return e;
}
Exemplo n.º 12
0
void RenderIndicator::layout()
{
    ASSERT(needsLayout());

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
    calcWidth();
    calcHeight();
    layoutParts();
    repainter.repaintAfterLayout();
    setNeedsLayout(false);
}
Exemplo n.º 13
0
void ItemUser::updateValues( af::Node *node, int type)
{
   af::User * user = (af::User*)node;

   permanent = user->isPermanent();
   if( numrunningtasks ) setRunning();
   else        setNotRunning();

   priority             = user->getPriority();
   annotation           = afqt::stoq( user->getAnnontation());
   hostname             = afqt::stoq( user->getHostName());
   numjobs              = user->getNumJobs();
   numrunningtasks      = user->getRunningTasksNumber();
   maxrunningtasks      = user->getMaxRunningTasks();
   hostsmask            = afqt::stoq( user->getHostsMask());
   hostsmask_exclude    = afqt::stoq( user->getHostsMaskExclude());
   errors_avoidhost     = user->getErrorsAvoidHost();
   errors_tasksamehost  = user->getErrorsTaskSameHost();
   errors_retries       = user->getErrorsRetries();
   errors_forgivetime   = user->getErrorsForgiveTime();
   jobs_lifetime        = user->getJobsLifeTime();

   if( numrunningtasks ) setRunning();
   else                  setNotRunning();

   strLeftTop = QString("%1-%2").arg(name).arg( priority);
   if( false == permanent ) strLeftTop = QString("(%1)").arg( strLeftTop);
   if( isLocked()) strLeftTop = "(LOCK) " + strLeftTop;

   strLeftBottom  = 'j' + QString::number( numjobs) + '/' + QString::number( user->getNumRunningJobs());

   strHCenterTop.clear();
   if( maxrunningtasks != -1) strHCenterTop  = QString("m%1").arg( maxrunningtasks );
   if( false == hostsmask.isEmpty()       )  strHCenterTop += QString(" H(%1)").arg( hostsmask         );
   if( false == hostsmask_exclude.isEmpty()) strHCenterTop += QString(" E(%1)").arg( hostsmask_exclude );
   strHCenterTop += QString(" %1").arg( user->generateErrorsSolvingString().c_str());
   if( jobs_lifetime > 0 ) strHCenterTop += QString(" L%1").arg( af::time2strHMS( jobs_lifetime, true).c_str());

   strRightTop = hostname;

    if( user->solveJobsParallel())
    {
        strRightBottom = "Par";
    }
    else
    {
        strRightBottom = "Ord";
    }

   tooltip = user->generateInfoString( true).c_str();

   calcHeight();
}
Exemplo n.º 14
0
void RenderSlider::layout()
{
    ASSERT(needsLayout());

    RenderBox* thumb = m_thumb ? toRenderBox(m_thumb->renderer()) : 0;

    IntSize baseSize(borderAndPaddingWidth(), borderAndPaddingHeight());

    if (thumb) {
        // Allow the theme to set the size of the thumb.
        if (thumb->style()->hasAppearance()) {
            // FIXME: This should pass the style, not the renderer, to the theme.
            theme()->adjustSliderThumbSize(thumb);
        }

        baseSize.expand(thumb->style()->width().calcMinValue(0), thumb->style()->height().calcMinValue(0));
    }

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());

    IntSize oldSize = size();

    setSize(baseSize);
    calcWidth();
    calcHeight();

    if (thumb) {
        if (oldSize != size())
            thumb->setChildNeedsLayout(true, false);

        LayoutStateMaintainer statePusher(view(), this, size());

        IntRect oldThumbRect = thumb->frameRect();

        thumb->layoutIfNeeded();

        IntRect rect = thumbRect();
        thumb->setFrameRect(rect);
        if (thumb->checkForRepaintDuringLayout())
            thumb->repaintDuringLayoutIfMoved(oldThumbRect);

        statePusher.pop();
        addOverflowFromChild(thumb);
    }

    repainter.repaintAfterLayout();    

    setNeedsLayout(false);
}
void RenderReplaced::layout()
{
    ASSERT(needsLayout());

    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());

    setHeight(minimumReplacedHeight());

    calcWidth();
    calcHeight();
    adjustOverflowForBoxShadowAndReflect();

    repainter.repaintAfterLayout();

    setNeedsLayout(false);
}
Exemplo n.º 16
0
void RenderReplaced::layout()
{
    ASSERT(needsLayout());
    
    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
    
    setHeight(minimumReplacedHeight());

    calcWidth();
    calcHeight();

    m_overflow.clear();
    addShadowOverflow();
    
    repainter.repaintAfterLayout();    

    setNeedsLayout(false);
}
Exemplo n.º 17
0
scalar KasmiMassonHill::height(scalar dist) const{

	// simple cases:
	if(dist >= a_) return 0.;
	if(dist < resolution()) return maxHeight_;

	// chop to resolution():
	label hi     = dist / resolution();
	scalar hdist = hi * resolution();

	// check if already calculated, calc otherwise:
	word k = hkey(hdist);
	if(!heightTable_.found(k)){
		heightTable_.set(k,calcHeight(hdist, 0., a_));
	}

	return heightTable_[k];

}
Exemplo n.º 18
0
void RenderSVGContainer::layout()
{
    ASSERT(needsLayout());

    calcViewport();

    // Arbitrary affine transforms are incompatible with LayoutState.
    view()->disableLayoutState();

    IntRect oldBounds;
    IntRect oldOutlineBox;
    bool checkForRepaint = checkForRepaintDuringLayout();
    if (selfNeedsLayout() && checkForRepaint) {
        oldBounds = m_absoluteBounds;
        oldOutlineBox = absoluteOutlineBox();
    }

    RenderObject* child = firstChild();
    while (child) {
        if (!child->isRenderPath() || static_cast<RenderPath*>(child)->hasRelativeValues())
            child->setNeedsLayout(true);

        child->layoutIfNeeded();
        ASSERT(!child->needsLayout());
        child = child->nextSibling();
    }

    calcWidth();
    calcHeight();

    m_absoluteBounds = absoluteClippedOverflowRect();
    if (!parent()->isSVGContainer()) {
        SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
        m_width = static_cast<int>(static_cast<float>(m_width) * svg->currentScale());
        m_height = static_cast<int>(static_cast<float>(m_height) * svg->currentScale());
    }

    if (selfNeedsLayout() && checkForRepaint)
        repaintAfterLayoutIfNeeded(oldBounds, oldOutlineBox);

    view()->enableLayoutState();
    setNeedsLayout(false);
}
Exemplo n.º 19
0
int main()
	{
	freopen("SUBST1.in","r",stdin);
	int casen;
	scanf("%d\n",&casen);
	while(casen-->0)
		{
		n=0;
		m=255;
		char tmp;
		memset(rank,0,sizeof(rank));
		while(scanf("%c",&tmp)!=EOF)
			{if(tmp=='\n')break;s[n++]=tmp;}
		long long  ans=n*(1+n)/2;
		s[n]=-1;
		da();
		calcHeight();
		for(int i=1;i<n;i++)
			ans-=height[i];
		printf("%lld\n",ans);
		}
	return 0;
	}
Exemplo n.º 20
0
void RenderReplaced::layout()
{
    ASSERT(needsLayout());

    IntRect oldBounds;
    IntRect oldOutlineBox;
    bool checkForRepaint = checkForRepaintDuringLayout();
    if (checkForRepaint) {
        oldBounds = absoluteClippedOverflowRect();
        oldOutlineBox = absoluteOutlineBox();
    }

    m_height = minimumReplacedHeight();

    calcWidth();
    calcHeight();
    adjustOverflowForBoxShadow();

    if (checkForRepaint)
        repaintAfterLayoutIfNeeded(oldBounds, oldOutlineBox);

    setNeedsLayout(false);
}
Exemplo n.º 21
0
void Hill::init()
{
	calcHeight();
}
Exemplo n.º 22
0
void ExportDialog::recalcRatio()
{
    if (cbRatio->isChecked()) {
        calcHeight();
    }
}
int main(void)
{
    initializeTree();
    while(1)
    {
        printf("\n1. Insert item. 2. Delete item. 3. Search item. \n");
        printf("4. Print height of tree. 5. Print height of an item. \n");
        printf("6. PrintInOrder. 7. Calculate Depth 8. get MinItem. 9. get MaxItem.\n10. Range search. 11. Delete. 12. exit.\n");

        int ch;
        scanf("%d",&ch);
        if(ch==1)
        {
            int item;
            scanf("%d", &item);
            insertItem(root, item);
        }
        else if(ch==2)
        {
            int item;
            scanf("%d", &item);
            deleteItem(root, item);
        }
        else if(ch==3)
        {
            int item;
            scanf("%d", &item);
            struct treeNode * res = searchItem(root, item);
            if(res!=0) printf("Found.\n");
            else printf("Not found.\n");
        }
        else if(ch==4)
        {
            int height = calcNodeHeight(root);
            printf("Height of tree = %d\n", height);
        }
        else if(ch==5)
        {
            int item;
            scanf("%d", &item);
            int height = calcHeight(item);
            printf("Height of %d = %d\n", item, height);
        }
        else if(ch==6)
        {
            int h = calcNodeHeight(root);
            printf("\n--------------------------------\n");
            printInOrder(root, h);
            printf("--------------------------------\n");
        }
        else if(ch==12)
        {
            break;
        }
        else if(ch==7)
        {
            int i;
            scanf("%d",&i);
            printf("depth %d\n",calcDepth(i));
        }


        else if(ch==8)
        {
            printf("min item %d\n",getMinItem());
        }
        else if(ch==9)
        {
            printf("max item %d\n",getMaxItem());
        }
        else if(ch==10)
        {
            int item1,item2;
            scanf("%d%d", &item1,&item2);
            printf("Item number %d",rangeSearch(root,item1,item2));

        }
        else if(ch==11)
        {
            int a;
            scanf("%d",&a);
            deleteItem(root,a);
        }
    }

}
Exemplo n.º 24
0
ExportDialog::ExportDialog(int w, int h, int wsel, int hsel, QString filename_, bool nosel_, QWidget *parent) :
    QDialog(parent)
{

    setCaption(tr("Export graphics"));
    dwidth = w;
    dheight = h;
    dwidthsel = wsel;
    dheightsel = hsel;
    svg = false;
    noselected = nosel_;

    filename = filename_;

    lblFilename = new QLabel(tr("Save to file (Graphics format by extension)"));
    lblResolutionX = new QLabel(tr("Width  in pixels"));
    lblResolutionY = new QLabel(tr("Height in pixels"));
    lblRatio = new QLabel(tr("Scale factor: "));
    lblFormat = new QLabel(tr("Image format:"));

    ExportButt = new QPushButton(tr("Export"));
    connect(ExportButt,SIGNAL(clicked()),this,SLOT(accept()));
    CancelButt = new QPushButton(tr("Cancel"));
    connect(CancelButt,SIGNAL(clicked()),this,SLOT(reject()));
    SaveButt = new QPushButton(tr("File"));
    connect(SaveButt,SIGNAL(clicked()),this,SLOT(setFileName()));

    editFilename = new QLineEdit(filename);
    connect(editFilename,SIGNAL(textChanged(QString)),this,SLOT(setSvg(QString)));

    editResolutionX = new QLineEdit(QString::number(dwidth));
    QIntValidator *val = new QIntValidator(0,64000,this);
    editResolutionX->setValidator(val);
    editResolutionX->setEnabled(false);
    editResolutionY = new QLineEdit(QString::number(dheight));
    editResolutionY->setValidator(val);
    editResolutionY->setEnabled(false);
    editScale = new QLineEdit(QString::number(1.0));
    QDoubleValidator *val1 = new QDoubleValidator(0,20.0,2,this);
    editScale->setValidator(val1);

    cbxImgType = new QComboBox(this);
    QStringList lst;
    lst<<tr("Colour")<<tr("Monochrome");
    cbxImgType->addItems(lst);

    cbRatio = new QCheckBox(tr("Original width to height ratio"));
    cbRatio->setChecked(true);
    connect(cbRatio,SIGNAL(toggled(bool)),this,SLOT(recalcRatio()));

    cbResolution = new QCheckBox(tr("Original size"));
    connect(cbResolution,SIGNAL(toggled(bool)),editResolutionX,SLOT(setDisabled(bool)));
    connect(cbResolution,SIGNAL(toggled(bool)),editResolutionY,SLOT(setDisabled(bool)));
    connect(cbResolution,SIGNAL(toggled(bool)),cbRatio,SLOT(setDisabled(bool)));
    connect(cbResolution,SIGNAL(toggled(bool)),editScale,SLOT(setDisabled(bool)));
    connect(cbResolution,SIGNAL(toggled(bool)),this,SLOT(restoreOriginalWtoH()));
    cbResolution->setChecked(true);

    connect(editResolutionX,SIGNAL(textEdited(QString)),this,SLOT(calcHeight()));
    connect(editResolutionY,SIGNAL(textEdited(QString)),this,SLOT(calcWidth()));
    connect(editScale,SIGNAL(textChanged(QString)),this,SLOT(recalcScale()));

    cbSelected = new QCheckBox(tr("Export selected only"));
    connect(cbSelected,SIGNAL(toggled(bool)),this,SLOT(setSelectedWH()));
    cbSelected->setChecked(false);
    if (noselected) cbSelected->setDisabled(true);

    //cbResolution->setEnabled(false);
    cbRatio->setEnabled(false);


    top = new QVBoxLayout;
    lower1 = new QHBoxLayout;
    lower2 = new QHBoxLayout;
    lower3 = new QHBoxLayout;
    lower4 = new QHBoxLayout;

    top->addWidget(lblFilename);
    lower1->addWidget(editFilename);
    lower1->addWidget(SaveButt);
    top->addLayout(lower1);
    lower4->addWidget(lblFormat);
    lower4->addWidget(cbxImgType);
    top->addLayout(lower4);
    top->addWidget(cbResolution);
    //top->addWidget(cbRatio);
    lower3->addWidget(lblRatio);
    lower3->addWidget(editScale);
    top->addLayout(lower3);
    top->addWidget(lblResolutionX);
    top->addWidget(editResolutionX);
    top->addWidget(lblResolutionY);
    top->addWidget(editResolutionY);
    top->addWidget(cbSelected);

    lower2->addWidget(ExportButt);
    lower2->addWidget(CancelButt);
    top->addLayout(lower2);
    this->setLayout(top);

    this->layout()->setSizeConstraint(QLayout::SetFixedSize);
    this->setWindowTitle(tr("Export schematic to raster or vector image"));

    this->setSvg(editFilename->text());
}
int main(void)
{
    //freopen("in2.txt", "r", stdin);
    initializeTree();
    while(1)
    {
        //printMenu();
        int ch;
        scanf("%d",&ch);
        if(ch == 1)
        {
            int item;
            scanf("%d", &item);
            insertItem(root, item);
        }
        else if(ch == 2)
        {
            int item;
            scanf("%d", &item);
            deleteItem(root, item);
        }
        else if(ch == 3)
        {
            int item;
            scanf("%d", &item);
            struct treeNode * res = searchItem(root, item);
            if(res!=0) printf("Found.\n");
            else printf("Not found.\n");
        }
        else if(ch == 4)
        {
            int height = calcNodeHeight(root);
            printf("Height of tree = %d\n", height);
        }
        else if(ch == 5)
        {
            int item;
            scanf("%d", &item);
            int height = calcHeight(item);
            printf("Height of %d = %d\n", item, height);
        }
        else if(ch == 6)
        {
            int h = calcNodeHeight(root);
            printf("\n--------------------------------\n");
            printInOrder(root, h);
            printf("--------------------------------\n");
        }
        else if(ch == 7)
        {
            printf("%d\n", getSize(root));
        }
        else if(ch == 8)
        {
            int item;
            scanf("%d", &item);
            printf("%d\n", calcDepth(item));
        }
        else if(ch == 9)
        {
            printf("%d\n", calcNodeDepth(root));
        }
        else if(ch == 10)
        {
            if(root == 0) {
                printf("tree is empty\n");
                continue;
            }
            printf("%d\n", getMinItem());
        }
        else if(ch == 11)
        {
            if(root == 0) {
                printf("tree is empty\n");
                continue;
            }
            printf("%d\n", getMaxItem());
        }
        else if(ch == 12)
        {
            int left, right;
            scanf("%d %d", &left, &right);
            printf("%d\n", rangeSearch(root, left, right));
        }
        else if(ch == 13)
        {
            int item;
            scanf("%d", &item);
            //printf("Del : %d\n", item);
            //deleteItem(root, item);
            printf("%d\n", deleteItem(root, item));
        }
        else if(ch == 14)
        {
            break;
        }
    }

}
Exemplo n.º 26
0
		/**
			Retain size and translate to a new center location.
		*/
		inline void setCenter( const Vector3& newCenterLoc )
		{
			Vector3 halfSize = Vector3( calcWidth(), calcHeight(), calcDepth() ) * 0.5f ;
			m_Min = newCenterLoc - halfSize;
			m_Max = newCenterLoc + halfSize;
		}
Exemplo n.º 27
0
 int minDepth(TreeNode* root) {
     return calcHeight(root);
 }