示例#1
0
long query(long index, long *arr, node *tree, long start, long end){
    long l, r;
    
    if ( tree[index].left > end || tree[index].right < start ) return NOTFOUND;
    if ( tree[index].left >= start && tree[index].right <= end ) return tree[index].val;
    l = query( leftChild(index), arr, tree, start, end);
    r = query ( rightChild(index), arr, tree, start, end);
    return minimumValue(arr, l, r);
}
示例#2
0
long initializeTree(long index, long *arr, node *tree, long start, long end){
    long mid, l, r;
    
    tree[index].left = start, tree[index].right = end;
    if ( start == end ) return tree[index].val = start;
    mid = (start + end)>>1;
    l = initializeTree( leftChild(index), arr, tree, start, mid );
    r = initializeTree( rightChild(index), arr, tree, mid + 1, end);
    return tree[index].val = minimumValue( arr, l, r );
}
示例#3
0
void MSTypeEntryField<Type>::decrement(void)
{
  if (MSView::model()!=0)
   {
     if (minimumValue().isSet()==MSTrue)
      {
	Type aType=value();
	aType-=incrementValue();
	if (aType>=minimumValue())
	 {
	   value()=aType;
	   valueChange();
	 }
      }
     else
      {
	value()-=incrementValue();
	valueChange();
      }
   }
}
示例#4
0
MSBoolean MSTypeEntryField<Type>::validate(const char *pString_)
{
  if (MSView::model()!=0)
   {
     Type aType;
     if (aType.set(pString_)==MSError::MSSuccess)
      {
	if (minimumValue().isSet()==MSTrue&&maximumValue().isSet()==MSTrue)
	 {
	   if (aType>=minimumValue()&&aType<=maximumValue())
	    {
	      value()=aType;
	      return MSTrue;
	    }
	 }
	else if (minimumValue().isSet()==MSTrue)
	 {
	   if (aType>=minimumValue())
	    {
	      value()=aType;
	      return MSTrue;
	    }
	 }
	else if (maximumValue().isSet()==MSTrue)
	 {
	   if (aType<=maximumValue())
	    {
	      value()=aType;
	      return MSTrue;
	    }
	 }
	else
	 {
	   value()=aType;
	   return MSTrue;
	 }
      }
   }
  return MSFalse;
}
示例#5
0
void Ruler::moveTo(qreal value, bool smooth)
{
    qreal newValue;

    if (value < minimumValue())
        newValue = minimumValue();
    else if (value > maximumValue())
        newValue = maximumValue();
    else {
        if (smooth || m_stepValue == 0.0) {
            newValue = value;
        } else if (value > 0.0) {
            newValue = value - fmod(value + m_stepValue * 0.5, m_stepValue) + m_stepValue * 0.5;
        } else {
            newValue = value - fmod(value - m_stepValue * 0.5, m_stepValue) - m_stepValue * 0.5;
        }
    }

    if (newValue != m_value) {
        m_value = newValue;
        emit needsRepaint();
    }
}
示例#6
0
void MSIntEntryField::decrement(void)
{
  if (MSView::model()!=0)
   {
     if (value() >= INT_MIN + incrementValue())   // prevent underflow
      {
       if (minimumValue().isSet()==MSTrue)
        {
          int anInt=value();
          anInt-=(int)incrementValue();
          if (anInt>=minimumValue())
           {
             value()=anInt;
             valueChange();
           }
        }
       else
        {
          value()-=incrementValue();
          valueChange();
        }
      }
   }
}
示例#7
0
void MSFloatEntryField::decrement(void)
{
  if (MSView::model()!=0)
   {
     if (value() >= -DBL_MAX + incrementValue())   // prevent underflow
      {
       if (minimumValue().isSet()==MSTrue)
        {
          double anFloat=value();
          anFloat-=incrementValue();
          if (anFloat>=minimumValue())
           {
             value()=anFloat;
             valueChange();
           }
        }
       else
        {
          value()-=incrementValue();
          valueChange();
        }
      }
   }
}
示例#8
0
void Ruler::decreaseByStep()
{
    qreal newValue = qMax(value() - stepValue(), minimumValue());
    setValue(newValue);
}