当前位置: 首页>>代码示例>>C++>>正文


C++ InRange函数代码示例

本文整理汇总了C++中InRange函数的典型用法代码示例。如果您正苦于以下问题:C++ InRange函数的具体用法?C++ InRange怎么用?C++ InRange使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了InRange函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HexStringToDword

// scan lpsz for a number of hex digits (at most 8); update lpsz, return
// value in Value; check for chDelim; return TRUE for success.
BOOL  HexStringToDword(LPCTSTR * lplpsz, DWORD * lpValue, int cDigits, TCHAR chDelim)
{
    int ich;
    LPCTSTR lpsz = *lplpsz;
    DWORD Value = 0;
    BOOL fRet = TRUE;

    for (ich = 0; ich < cDigits; ich++)
    {
        TCHAR ch = lpsz[ich];
        if (InRange(ch, TEXT('0'), TEXT('9')))
        {
            Value = (Value << 4) + ch - TEXT('0');
        }
        else if ( InRange( (ch |= (TEXT('a')-TEXT('A'))), TEXT('a'), TEXT('f')) )
        {
            Value = (Value << 4) + ch - TEXT('a') + 10;
        }
        else
            return(FALSE);
    }

    if (chDelim)
    {
        fRet = (lpsz[ich++]==chDelim);
    }

    *lpValue = Value;
    *lplpsz = lpsz+ich;

    return fRet;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:34,代码来源:ole2dup.c

示例2: Try

void Try(int x, int y)
{
	int i;
	for(i=0; i<8; i++)
	{
		if(!InRange(x+dx[i])) continue;
		if(!InRange(y+dy[i])) continue;
		if(bVisited[x+dx[i]][y+dy[i]]) continue;
		
		bVisited[x+dx[i]][y+dy[i]] = 1;
		cntVisited ++;
		seqVisited[x+dx[i]][y+dy[i]] = ++seq;
		if(cntVisited == (N+1)*(N+1))
			FindSolution();
		else
		{
			if(x==4 && y==3)
			{
				int x6=0;
				x6++;
			}
			Try(x+dx[i], y+dy[i]);
		}
		bVisited[x+dx[i]][y+dy[i]] = 0;
		cntVisited --;
		seqVisited[x+dx[i]][y+dy[i]] =0,  seq--;
	}
}
开发者ID:lizy14,项目名称:C-assignments,代码行数:28,代码来源:main.cpp

示例3: switch

bool Value::isConvertibleTo(ValueType other) const {
  switch (other) {
  case nullValue:
    return (isNumeric() && asDouble() == 0.0) ||
           (type_ == booleanValue && value_.bool_ == false) ||
           (type_ == stringValue && asString() == "") ||
           (type_ == arrayValue && value_.map_->size() == 0) ||
           (type_ == objectValue && value_.map_->size() == 0) ||
           type_ == nullValue;
  case intValue:
    return isInt() ||
           (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
           type_ == booleanValue || type_ == nullValue;
  case uintValue:
    return isUInt() ||
           (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||
           type_ == booleanValue || type_ == nullValue;
  case realValue:
    return isNumeric() || type_ == booleanValue || type_ == nullValue;
  case booleanValue:
    return isNumeric() || type_ == booleanValue || type_ == nullValue;
  case stringValue:
    return isNumeric() || type_ == booleanValue || type_ == stringValue ||
           type_ == nullValue;
  case arrayValue:
    return type_ == arrayValue || type_ == nullValue;
  case objectValue:
    return type_ == objectValue || type_ == nullValue;
  }
  JSON_ASSERT_UNREACHABLE;
  return false;
}
开发者ID:4ib3r,项目名称:domoticz,代码行数:32,代码来源:json_value.cpp

示例4: numDecodings

 int numDecodings(string s) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     if(s.size() == 0) return 0;
     vector<int> dp(s.size(), 0);
     int num = 0;
     
     //Initialize
     int iter = s.size() - 1;
     if(InRange(s[iter] - '0', 1, 26)) dp[iter] = 1;
     if(--iter >= 0) {
         num = s[iter] - '0';
         if(InRange(num, 1, 26)) {
             dp[iter] += dp[iter + 1];
             num = num * 10 + s[iter + 1] - '0';
             if(InRange(num, 1, 26)) dp[iter] += 1;
         }
     }
     
     for(iter = s.size() - 3; iter >= 0; --iter) {
         num = 0;
         for(int j = iter; j <= iter + 1; ++j) {
             num = num * 10 + s[j] - '0';
             if(InRange(num, 1, 26)) dp[iter] += dp[j + 1];
             else break;
         }
     }
     return dp[0];
 }
开发者ID:tommengdel,项目名称:Leetcode,代码行数:29,代码来源:DecodeWays.cpp

示例5: GetBits

int GetBits(char x)
{
    if (InRange((char) (x & (~0x20)), 'A', 'F'))
    {
        return (x & (~0x20)) - 'A' + 0xa;
    }
    else if (InRange(x, '0', '9'))
    {
        return x - '0';
    }

    return 0;
}
开发者ID:UNKN-0WN,项目名称:cathook,代码行数:13,代码来源:CSignature.cpp

示例6: Vec2

void SplitterSystem::InitParticle(Particle *p) {
	p->mPos = emitter.mPosition;
	p->mVel = Vec2(5, 5);
	p->mAcc = Vec2(10, 10);
	p->mMaxTime = InRange(emitter.mParams.mMinLifeTimeMs, emitter.mParams.mMaxLifeTimeMs) / 1000.0f;
	p->mTime = p->mMaxTime;
	p->mOrientation = InRange(0.0f, 3.141592f * 2.0f);
	p->mTint = Color::White;
	p->mScale = Vec2(1, 1);
	p->mAngularVelocity = r2() * .008f;
	p->mDir = { InRange(-.6f, .6f), InRange(-.6f, .6f) };

	p->mAcc = Vec2(r2() * 70, r1() * -750);
}
开发者ID:syvjohan,项目名称:Games,代码行数:14,代码来源:SplitterSystem.cpp

示例7: GetPos

bool wxGBSizerItem::Intersects(const wxGBPosition& pos, const wxGBSpan& span)
{

    int row, col, endrow, endcol;
    int otherrow, othercol, otherendrow, otherendcol;

    GetPos(row, col);
    GetEndPos(endrow, endcol);

    otherrow = pos.GetRow();
    othercol = pos.GetCol();
    otherendrow = otherrow + span.GetRowspan() - 1;
    otherendcol = othercol + span.GetColspan() - 1;

    // is the other item's start or end in the range of this one?
    if (( InRange(otherrow, row, endrow) && InRange(othercol, col, endcol) ) ||
        ( InRange(otherendrow, row, endrow) && InRange(otherendcol, col, endcol) ))
        return true;

    // is this item's start or end in the range of the other one?
    if (( InRange(row, otherrow, otherendrow) && InRange(col, othercol, otherendcol) ) ||
        ( InRange(endrow, otherrow, otherendrow) && InRange(endcol, othercol, otherendcol) ))
        return true;

    return false;
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:26,代码来源:gbsizer.cpp

示例8: GetNode

void WireSim::PowerAdjacentNodes( int x, int y, bool respectChannels )
{
	WireNode activeNode = GetNode( x, y, m_activeBuffer );
	for( int dx = -1; dx <= 1; dx++ )
	{
		for( int dy = -1; dy <= 1; dy++ )
		{
			// Only directly-adjacent
			if( ( dx == 0 || dy == 0 ) && InRange( x + dx, y + dy ) )
			{
				// Affect anything except none-type and only no-powered nodes
				WireNode& nextNode = GetNode( x + dx, y + dy, m_nextBuffer );

                bool isNoneType = WireNodeType(nextNode.m_type) == cWireNodeType_None;
				bool sharesChannels = ( nextNode.m_channels & activeNode.m_channels ) != 0;

				if( ( !respectChannels || ( respectChannels && sharesChannels ) ) &&
					( !isNoneType && nextNode.m_power == 0 ) )
				{
					// Max out power
					nextNode.m_power |= WireNode::cMaxPower;
				}
			}
		}
	}
}
开发者ID:nint22,项目名称:WireNode,代码行数:26,代码来源:wiresim.cpp

示例9: __FLOG

void CEventBattery::HandlePhoneEventL(TPhoneFunctions event)
	{
	__FLOG(_L("HandlePhoneEventL()"));
	
	if (event != ENotifyBatteryStatusChange)
		return;

	if (InRange())
		{
		// inside range
		// Before trigger the event perform an additional check, just in case.
		if (!iWasInRange)
			{
			iWasInRange = ETrue;
			// Triggers the In-Action
			SendActionTriggerToCoreL();
			}
		}
	else
		{
		// not connected
		if (iWasInRange)
			{
			iWasInRange = EFalse;
			// Triggers the unplug action
			if (iBatteryParams.iExitAction != 0xFFFFFFFF)
				{
				SendActionTriggerToCoreL(iBatteryParams.iExitAction);
				}
			}
		}
	iPhone->NotifyBatteryStatusChange(iBatteryInfoPckg);
	}
开发者ID:BwRy,项目名称:core-symbian,代码行数:33,代码来源:EventBattery.cpp

示例10: OutputSprite

void Sprites::OutputSprite(ULO spriteNo, ULO startCylinder, ULO cylinderCount)
{
    if (SpriteState[spriteNo].armed)
    {
        ULO pixel_index = 0;

        // Look for start of sprite output
        if (!SpriteState[spriteNo].serializing && InRange(spriteNo, startCylinder, cylinderCount))
        {
            SpriteState[spriteNo].serializing = true;
            pixel_index = SpriteState[spriteNo].x - startCylinder + 1;
        }
        if (SpriteState[spriteNo].serializing)
        {
            // Some output of the sprite will occur in this range.
            ULO pixel_count = cylinderCount - pixel_index;
            ULO pixelsLeft = 16 - SpriteState[spriteNo].pixels_output;
            if (pixel_count > pixelsLeft)
            {
                pixel_count = pixelsLeft;
            }

            if (BitplaneUtility::IsHires())
            {
                pixel_index *= 2;  // Hires coordinates
            }

            Merge(spriteNo, SpriteState[spriteNo].pixels_output, pixel_index, pixel_count);
            SpriteState[spriteNo].pixels_output += pixel_count;
            SpriteState[spriteNo].serializing = (SpriteState[spriteNo].pixels_output < 16);
        }
    }
}
开发者ID:petschau,项目名称:WinFellow,代码行数:33,代码来源:SpriteState.c

示例11: tanf

void D435DepthNoiseModel::ApplyNoise(const uint32_t width,
                                     const uint32_t height, float *data) {
  if (data == nullptr) {
    return;
  }

  float f = 0.5f * (width / tanf(h_fov / 2.0f));
  float multiplier = (subpixel_err) / (f * baseline * 1e6f);
  Eigen::Map<Eigen::VectorXf> data_vector_map(data, width * height);

  // Formula taken from the Intel Whitepaper:
  // "Best-Known-Methods for Tuning Intel RealSense™ D400 Depth Cameras for Best Performance".
  // We are using the theoretical RMS model formula.
  Eigen::VectorXf rms_noise = (data_vector_map * 1000.0).array().square() * multiplier;
  Eigen::VectorXf noise = rms_noise.array().square();

  // Sample noise for each pixel and transform variance according to error at this depth.
  for (int i = 0; i < width * height; ++i) {
    if (InRange(data_vector_map[i])) {
      data_vector_map[i] +=
          this->dist(this->gen) * std::min(((float)noise(i)), max_stdev);
    } else {
      data_vector_map[i] = this->bad_point;
    }
  }
}
开发者ID:ethz-asl,项目名称:rotors_simulator,代码行数:26,代码来源:depth_noise_model.cpp

示例12: SampleDiscrete

    // --------------------------------------------------
    void SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const
    {
        ai_assert(InRange(a) && InRange(b));

        const size_t cnt = EstimateSampleCount(a,b);
        out.verts.reserve(out.verts.size() + cnt);

        BOOST_FOREACH(const CurveEntry& entry, curves) {
            const size_t cnt = out.verts.size();
            entry.first->SampleDiscrete(out);

            if (!entry.second && cnt != out.verts.size()) {
                std::reverse(out.verts.begin()+cnt,out.verts.end());
            }
        }
    }
开发者ID:03050903,项目名称:Urho3D,代码行数:17,代码来源:IFCCurve.cpp

示例13: OnRunway

bool Aircraft::Colliding(const Aircraft &Other) const
{
    const sf::Vector2f &Me = Shape.getPosition();
    const sf::Vector2f &Pos = Other.Shape.getPosition();
    return OnRunway() == Other.OnRunway() &&
           InRange(Me, Pos, (Radius + Other.Radius) / 1.3f);
}
开发者ID:sim642,项目名称:AirTraffic,代码行数:7,代码来源:Aircraft.cpp

示例14: round

// When we want to check for collisions we check the 8 surrounding
// squares; I chose this because the bounding spheres method looked
// ugly
void MazeGame::DetectCollisions(Float3 &offset) {
	// Get the position of the player in the maze matrix
	int x = round(player_->x / cube_size_);
	int y = round(player_->z / cube_size_);

	// For each of the 8 surrounding squares
	for (int i = -1; i <= 1; ++i)
		for (int j = -1; j <= 1; ++j) {
			if (i == 0 && j == 0)
				continue;

/* I chose to leave this commented because it did not behave as I wanted;
 * It prevents my sphere to pass through cube corners (checks the diagonal
 * cubes for collisions) but the movement is not natural at all
 * (the sphere tends to glitch when moving while hugging a wall)

		if (i != 0 && j != 0 && actual_maze_[x + i][y + j] == '#')
			if (InRange((player_->x + offset.x), ((x + i) * cube_size_)) &&
				InRange((player_->z + offset.z), ((y + j) * cube_size_))) {
					offset.x = 0;
					offset.z = 0;
			}
*/

			if (i != 0 && actual_maze_[x + i][y] == '#')
				if (InRange((player_->x + offset.x),
							((x + i) * cube_size_)))
					offset.x = 0;

			if (j != 0 && actual_maze_[x][y + j] == '#')
				if (InRange((player_->z + offset.z),
							((y + j) * cube_size_)))
					offset.z = 0;
		}

	// If the "portal" is reached we just spawn it
	// somwhere else (we're devilishly intelligent!);
	// Doing so will prevent our little ball from ever
	// leaving the labyrinth! Mwahahahaha!
	if (x == round(portal_->x / cube_size_) &&
		y == round(portal_->z / cube_size_)) {
			portal_->x = -1;
			++score_;
			PlaceRandObject(portal_);
	}
}
开发者ID:Mondobot,项目名称:Labyrinth,代码行数:49,代码来源:maze_game.cpp

示例15: VERIFY_MODEL

void Hex::SetSquareOccupied(int i, bool b)
{
    VERIFY_MODEL(InRange(m_squares, i));
    if (b)
        m_occupied.insert(i);
    else
        m_occupied.erase(i);
}
开发者ID:molip,项目名称:Eclipsoid,代码行数:8,代码来源:Hex.cpp


注:本文中的InRange函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。