コード例 #1
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::Pos JSON::skipArray() const
{
    //std::cerr << "skipArray()\t" << data() << std::endl;

    if (!isArray())
        throw JSONException("JSON: expected [");
    Pos pos = ptr_begin;
    ++pos;
    checkPos(pos);
    if (*pos == ']')
        return ++pos;

    while (1)
    {
        pos = JSON(pos, ptr_end, level + 1).skipElement();

        checkPos(pos);

        switch (*pos)
        {
            case ',':
                ++pos;
                break;
            case ']':
                return ++pos;
            default:
                throw JSONException(std::string("JSON: expected one of ',]', got ") + *pos);
        }
    }
}
コード例 #2
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::Pos JSON::skipObject() const
{
    //std::cerr << "skipObject()\t" << data() << std::endl;

    if (!isObject())
        throw JSONException("JSON: expected {");
    Pos pos = ptr_begin;
    ++pos;
    checkPos(pos);
    if (*pos == '}')
        return ++pos;

    while (1)
    {
        pos = JSON(pos, ptr_end, level + 1).skipNameValuePair();

        checkPos(pos);

        switch (*pos)
        {
            case ',':
                ++pos;
                break;
            case '}':
                return ++pos;
            default:
                throw JSONException(std::string("JSON: expected one of ',}', got ") + *pos);
        }
    }
}
コード例 #3
0
ファイル: pic_code.c プロジェクト: pg8/ME433
/*void textSpeed(void) {
    while (1) {
    _CP0_SET_COUNT(0); // set core timer to 0, remember it counts at half the CPU clock
    LATBINV = some_pin; // invert a pin

    // wait for half a second, setting LED brightness to pot angle while waiting
    while (_CP0_GET_COUNT() < 10000000) {
        val = readADC();
        OC1RS = val * normalize_to_pr;

        if (push_button_pin == 1) {
            // nothing
        } else {
            LATBINV = some_pin;
        }
    }
}
}*/
void drawChar(int tableIndex, int xPos, int yPos){
    //int check;
    int i;
    int j;
    char number;
    int check1;
    int check2;



    check1 = checkPos(xPos,yPos); //see if this position works
    check2 = checkPos(xPos+4,yPos+7);
    if(check1&&check2){
        for(i=0;i<5;i++){
            number = ASCII[tableIndex][i];
            for(j=0;j<=7;j++){
                //if((((int)number)&(1<<j))>>j){
                if(((int)number>>j)&1==1){
                    display_pixel_set(yPos+j,xPos+i,1);
                }
                else{
                    display_pixel_set(yPos+j,xPos+i,0);
                }
            }
        }
    }
コード例 #4
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON JSON::getValue() const
{
    Pos pos = skipString();
    checkPos(pos);
    if (*pos != ':')
        throw JSONException("JSON: expected :.");
    ++pos;
    checkPos(pos);
    return JSON(pos, ptr_end, level + 1);
}
コード例 #5
0
ファイル: kdtree.cpp プロジェクト: Branden-Turner/DirectXApps
  static void CountVertPositions( const Triangle& tri, unsigned& left, unsigned& right, unsigned& cop, SplitAxis axis, float pos )
  {
    float p1, p2, p3;

    switch(axis)
    {
      case XAxis:
        p1 = tri.p1.x;
        p2 = tri.p2.x;
        p3 = tri.p3.x;
        checkPos(p1, left, right, cop, pos);
        checkPos(p2, left, right, cop, pos);
        checkPos(p3, left, right, cop, pos);

      break;

      case YAxis:
        p1 = tri.p1.y;
        p2 = tri.p2.y;
        p3 = tri.p3.y;
        checkPos(p1, left, right, cop, pos);
        checkPos(p2, left, right, cop, pos);
        checkPos(p3, left, right, cop, pos);
      break;

      case ZAxis:
        p1 = tri.p1.z;
        p2 = tri.p2.z;
        p3 = tri.p3.z;
        checkPos(p1, left, right, cop, pos);
        checkPos(p2, left, right, cop, pos);
        checkPos(p3, left, right, cop, pos);
      break;
    }
  }
コード例 #6
0
bool ChessModel::isSwapable(char player, QPair<int, int> st, QPair<int, int> ed) const
{
    if (player == 'A') {
        st.first = 14 - st.first;
        st.second = 6 - st.second;
        ed.first = 14 - ed.first;
        ed.second = 6 - ed.second;
    }
    int x = getChessId(player, st), y = getChessId(player, ed);
    if (x == -1 || y == -1) return 0;
    return checkPos(pieceType[x], ed) && checkPos(pieceType[y], st);
}
コード例 #7
0
ファイル: PathFinder.cpp プロジェクト: highjin/ProjectArthas
bool PathFinder::findWay(Tag nextCheckTag)
{
	std::priority_queue<Tag, std::vector<Tag>, Compare> openTags;
	int checkResult = FAIL;
	cocos2d::Point checkingPos;
	m_CurTag = nextCheckTag;

	for(int dir = DIR_UP; dir < DIR_MAX; ++dir)
	{
		checkingPos = findNeighbor(dir);
		checkResult |= checkPos(checkingPos, &openTags);
		if(checkResult & FIND)
		{
			return true;
		}
	}

	if(checkResult & CHECKING)
	{
		while(!openTags.empty())
		{
   			Tag nextTag = openTags.top();
			if(findWay(nextTag))
			{
				m_Path.push(cocos2d::Point(nextTag.m_X, nextTag.m_Y));
				return true;
			}
			openTags.pop();
		}
	}
	return false;
}
コード例 #8
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::Pos JSON::skipNumber() const
{
    //std::cerr << "skipNumber()\t" << data() << std::endl;

    Pos pos = ptr_begin;

    checkPos(pos);
    if (*pos == '-')
        ++pos;

    while (pos < ptr_end && *pos >= '0' && *pos <= '9')
        ++pos;
    if (pos < ptr_end && *pos == '.')
        ++pos;
    while (pos < ptr_end && *pos >= '0' && *pos <= '9')
        ++pos;
    if (pos < ptr_end && (*pos == 'e' || *pos == 'E'))
        ++pos;
    if (pos < ptr_end && *pos == '-')
        ++pos;
     while (pos < ptr_end && *pos >= '0' && *pos <= '9')
        ++pos;

    return pos;
}
コード例 #9
0
ファイル: 1157.c プロジェクト: UsuallyGO/POJ
int main()
{
    int i, j;
    int max;

    while(scanf("%d %d", &f, &v) != EOF)
    {
    memset(weight, 0, sizeof(weight));
    init();
    for(i = 0; i < f; i++)
    {
	for(j = 0; j < v; j++)
	    scanf("%d", &weight[i][j]);
    }

    dp[0][0] = weight[0][0];
    for(i = 0; i < f; i++)
    {
	max = dp[i][0];
	for(j = i; j < v; j++)
	{
	    if(weight[i][j] > max)
		max = weight[i][j];

	    dp[i][j] = max;
	}
    }

#if DEBUG
    showDP();
#endif

    for(i = 0; i < f; i++)
    {
	for(j = i; j < v; j++)
	{
	    if(checkPos(i-1, j-1))
	    {
		if(i == j)
		    dp[i][j] = dp[i-1][j-1] + weight[i][j];
		else
		    dp[i][j] = Max(dp[i-1][j-1] + weight[i][j], dp[i][j-1]); 
	    }
	}
    }
#if DEBUG
    showDP();
#endif

    max = MINIMAL;
    for(j = 0; j < v; j++)
    {
	if(dp[f-1][j] > max)
	    max = dp[f-1][j];
    }
    printf("%d\n", max);
    }

    return 0;
}
コード例 #10
0
ファイル: bird.cpp プロジェクト: AriesandMill/pd2-angrybird
void Bird::launch(b2Vec2 velocity)
{
    invulnerability=false;

    launched = true;
    g_size = QSizeF(g_worldsize.height()*ratio,g_worldsize.height()*ratio);
    QPointF mapped;
    mapped.setX((g_pixmap.x()+g_pixmap.pixmap().width()/2)/g_windowsize.width()*g_worldsize.width());
    mapped.setY((1.0f-(g_pixmap.y()+g_pixmap.pixmap().height()/2)/g_windowsize.height())*g_worldsize.height());

    // Create Body
    b2BodyDef bodydef;
    bodydef.type = b2_dynamicBody;
    bodydef.position.Set(mapped.x(),mapped.y());

    bodydef.userData = this;
    g_body = g_world->CreateBody(&bodydef);

    b2CircleShape bodyshape;
    bodyshape.m_radius = g_worldsize.height()*ratio/2;

    b2FixtureDef fixturedef;
    fixturedef.shape = &bodyshape;
    fixturedef.density = BIRD_DENSITY;
    fixturedef.friction = BIRD_FRICTION;
    fixturedef.restitution = BIRD_RESTITUTION;
    g_body->CreateFixture(&fixturedef);
    g_body->SetAngularDamping(1);
    g_body->SetLinearVelocity(velocity);

    connect(g_timer, SIGNAL(timeout()), this,SLOT(paint()));
    connect(g_timer, SIGNAL(timeout()), this, SLOT(checkPos()));
    connect(g_timer, SIGNAL(timeout()), this, SLOT(checkVelocity()));
}
コード例 #11
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::iterator & JSON::iterator::operator++()
{
    Pos pos = skipElement();
    checkPos(pos);

    if (*pos != ',')
        ptr_begin = nullptr;
    else
    {
        ++pos;
        checkPos(pos);
        ptr_begin = pos;
    }

    return *this;
}
コード例 #12
0
uint32 BitPumpJPEG::getBitsSafe(unsigned int nbits) {
  if (nbits > MIN_GET_BITS)
    throw IOException("Too many bits requested");

  fill();
  checkPos();
  return getBitsNoFill(nbits);
}
コード例 #13
0
ファイル: FPSView.cpp プロジェクト: ariste1a/cse167
/**
 * Sprint right.
 *
 * @param map	Collision map
 */
void FPSView::sprintRight(CollisionMap2D &map) {
	mEye.subtract(mScaleLeft);
	mCenter.subtract(mScaleLeft);

	if (!checkPos(map)) {
		mEye.add(mScaleLeft);
		mCenter.add(mScaleLeft);
	}
}
コード例 #14
0
ファイル: FPSView.cpp プロジェクト: ariste1a/cse167
/**
 * Sprint forward.
 *
 * @param map	Collision map
 */
void FPSView::sprintForward(CollisionMap2D &map) {
	mEye.add(mScaleXZDirection);
	mCenter.add(mScaleXZDirection);

	if (!checkPos(map)) {
		mEye.subtract(mScaleXZDirection);
		mCenter.subtract(mScaleXZDirection);
	}
}
コード例 #15
0
ファイル: FPSView.cpp プロジェクト: ariste1a/cse167
/**
 * Walk right.
 *
 * @param map	Collision map
 */
void FPSView::walkRight(CollisionMap2D &map) {
	mEye.subtract(mLeft);
	mCenter.subtract(mLeft);

	if (!checkPos(map)) {
		mEye.add(mLeft);
		mCenter.add(mLeft);
	}
}
コード例 #16
0
ファイル: FPSView.cpp プロジェクト: ariste1a/cse167
/**
 * Walk backward.
 *
 * @param map	Collision map
 */
void FPSView::walkBack(CollisionMap2D &map) {
	mEye.subtract(mXZDirection);
	mCenter.subtract(mXZDirection);

	if (!checkPos(map)) {
		mEye.add(mXZDirection);
		mCenter.add(mXZDirection);
	}
}
コード例 #17
0
ファイル: FPSView.cpp プロジェクト: ariste1a/cse167
/**
 * Move in arbitrary direction.
 *
 * @param x		X distance to move.
 * @param y		Y distance to move.
 * @param z		Z distance to move.
 * @param map	Collision map
 */
void FPSView::move(double x, double y, double z, CollisionMap2D &map) {
	Vector3Mike dir(x, 0, z);
	mEye.add(dir);
	mCenter.add(dir);

	if (!checkPos(map)) {
		mEye.subtract(dir);
		mCenter.subtract(dir);
	}
}
コード例 #18
0
ファイル: FPSView.cpp プロジェクト: ariste1a/cse167
/**
 * Move in arbitrary direction.
 *
 * @param dir	Direction and distance to move.
 * @param map	Collision map
 */
void FPSView::move(Vector3Mike dir, CollisionMap2D &map) {
	dir = Vector3Mike(dir.get_x(), 0, dir.get_z());
	mEye.add(dir);
	mCenter.add(dir);

	if (!checkPos(map)) {
		mEye.subtract(dir);
		mCenter.subtract(dir);
	}
}
コード例 #19
0
ファイル: BitPumpMSB32.cpp プロジェクト: EvilBit/darktable
uint32 BitPumpMSB32::getBitsSafe(unsigned int nbits) {
  if (nbits > MIN_GET_BITS)
    throw IOException("Too many bits requested");

  if (mLeft < nbits) {
    fill();
    checkPos();
  }

  return (uint32)((mCurr >> (mLeft -= (nbits))) & ((1 << nbits) - 1));
}
コード例 #20
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::Pos JSON::skipString() const
{
    //std::cerr << "skipString()\t" << data() << std::endl;

    Pos pos = ptr_begin;
    checkPos(pos);
    if (*pos != '"')
        throw JSONException(std::string("JSON: expected \", got ") + *pos);
    ++pos;

    /// fast path: находим следующую двойную кавычку. Если перед ней нет бэкслеша - значит это конец строки (при допущении корректности JSON).
    Pos closing_quote = reinterpret_cast<const char *>(memchr(reinterpret_cast<const void *>(pos), '\"', ptr_end - pos));
    if (nullptr != closing_quote && closing_quote[-1] != '\\')
        return closing_quote + 1;

    /// slow path
    while (pos < ptr_end && *pos != '"')
    {
        if (*pos == '\\')
        {
            ++pos;
            checkPos(pos);
            if (*pos == 'u')
            {
                pos += 4;
                checkPos(pos);
            }
        }
        ++pos;
    }

    checkPos(pos);
    if (*pos != '"')
        throw JSONException(std::string("JSON: expected \", got ") + *pos);
    ++pos;

    return pos;
}
コード例 #21
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::Pos JSON::skipNameValuePair() const
{
    //std::cerr << "skipNameValuePair()\t" << data() << std::endl;

    Pos pos = skipString();
    checkPos(pos);

    if (*pos != ':')
        throw JSONException("JSON: expected :.");
    ++pos;

    return JSON(pos, ptr_end, level + 1).skipElement();

}
コード例 #22
0
ファイル: AFileVarsManager.cpp プロジェクト: Protoxy-/Zappy
int         AFileVarsManager::get(std::string const &name)
{
  std::string   _name;
  int  pos;

  _name = name;
  pos = checkPos(name);
  if (pos != -1)
    _name = name.substr(0, name.size() - 2);
  else
    pos = 0;

  if (_vars.find(_name) == _vars.end())
    throw errLogical("No var called \"" + _name + "\" in file \"" + _path);
  return ((*_vars.find(_name)->second)[pos]);
}
コード例 #23
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::iterator JSON::iterator::begin() const
{
    ElementType type = getType();

    if (type != TYPE_ARRAY && type != TYPE_OBJECT)
        throw JSONException("JSON: not array or object when calling begin() method.");

    //std::cerr << "begin()\t" << data() << std::endl;

    Pos pos = ptr_begin + 1;
    checkPos(pos);
    if (*pos == '}' || *pos == ']')
        return end();

    return JSON(pos, ptr_end, level + 1);
}
コード例 #24
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON::Pos JSON::skipBool() const
{
    //std::cerr << "skipBool()\t" << data() << std::endl;

    Pos pos = ptr_begin;
    checkPos(pos);

    if (*ptr_begin == 't')
        pos += 4;
    else if (*ptr_begin == 'f')
        pos += 5;
    else
        throw JSONException("JSON: expected true or false.");

    return pos;
}
コード例 #25
0
ファイル: AFileVarsManager.cpp プロジェクト: Protoxy-/Zappy
void  AFileVarsManager::set(std::string const &name, int val)
{
  std::string   _name;
  int  pos;

  _name = name;
  pos = checkPos(name);
  if (pos != -1)
  {
    _name = name.substr(0, name.size() - 2);
  }
  else
    pos = 0;
  if (_vars.find(_name) == _vars.end())
    throw errLogical("No var called \"" + _name + "\" in file \"" + _path);
  (*_vars.find(_name)->second)[pos] = val;
  _change = 1;
}
コード例 #26
0
ファイル: JSON.cpp プロジェクト: bamx23/ClickHouse
JSON JSON::operator[] (size_t n) const
{
    ElementType type = getType();

    if (type != TYPE_ARRAY)
        throw JSONException("JSON: not array when calling operator[](size_t) method.");

    Pos pos = ptr_begin;
    ++pos;
    checkPos(pos);

    size_t i = 0;
    const_iterator it = begin();
    while (i < n && it != end())
        ++it, ++i;

    if (i != n)
        throw JSONException("JSON: array index " + Poco::NumberFormatter::format(Poco::UInt64(n)) + " out of bounds.");

    return *it;
}
コード例 #27
0
ファイル: ETQW_BaseStates.cpp プロジェクト: fishxz/omni-bot
	State::StateStatus BuildConstruction::Update( float fDt )
	{
		if ( DidPathFail() )
		{
			BlackboardDelay( 10.f, mMapGoal->GetSerialNum() );
			return State_Finished;
		}

		if ( !mMapGoal->IsAvailable( GetClient()->GetTeam() ) )
			return State_Finished;

		//////////////////////////////////////////////////////////////////////////
		// Check the construction status
		ConstructableState cState = InterfaceFuncs::GetConstructableState( GetClient(), mMapGoal->GetEntity() );
		switch ( cState )
		{
			case CONST_INVALID: // Invalid constructable, fail
				return State_Finished;
			case CONST_BUILT:	// It's built, consider it a success.
				return State_Finished;
			case CONST_UNBUILT:
			case CONST_BROKEN:
				// This is what we want.
				break;
		}
		//////////////////////////////////////////////////////////////////////////

		if ( DidPathSucceed() )
		{
			float fDistanceToConstruction = ( mConstructionPos - GetClient()->GetPosition() ).SquaredLength();
			if ( fDistanceToConstruction > 4096.0f )
			{
				// check for badly waypointed maps
				if ( !mAdjustedPosition )
				{
					// use our z value because some trigger entities may be below the ground
					Vector3f checkPos( mConstructionPos.X(), mConstructionPos.Y(), GetClient()->GetEyePosition().Z() );

					obTraceResult tr;
					EngineFuncs::TraceLine( tr, GetClient()->GetEyePosition(), checkPos,
						NULL, ( TR_MASK_SOLID | TR_MASK_PLAYERCLIP ), GetClient()->GetGameID(), True );

					if ( tr.mFraction != 1.0f && !tr.mHitEntity.IsValid() )
					{
						mMapGoal->SetDeleteMe( true );
						return State_Finished;
					}

					// do a trace to adjust position
					EngineFuncs::TraceLine( tr,
						GetClient()->GetEyePosition(),
						mConstructionPos,
						NULL, ( TR_MASK_SOLID | TR_MASK_PLAYERCLIP ), -1, False );

					if ( tr.mFraction != 1.0f )
					{
						mConstructionPos = *(Vector3f*)tr.mEndpos;
					}

					mAdjustedPosition = true;
				}
			}
			else
			{
				FINDSTATEIF( Aimer, GetRootState(), AddAimRequest( Priority::Medium, this, GetNameHash() ) );
				FINDSTATEIF( WeaponSystem, GetRootState(), AddWeaponRequest( Priority::Medium, GetNameHash(), ETQW_WP_PLIERS ) );
			}
			GetClient()->GetSteeringSystem()->SetTarget( mConstructionPos, 64.f );
		}
		return State_Busy;
	}
コード例 #28
0
uint32 BitPumpJPEG::getBitSafe() {
  fill();
  checkPos();

  return getBitNoFill();
}
コード例 #29
0
uchar8 BitPumpJPEG::getByteSafe() {
  fill();
  checkPos();
  return getBitsNoFill(8);
}
コード例 #30
0
ファイル: newSequence.cpp プロジェクト: DevilPandaKnight/CS32
bool Sequence::erase(int pos){
    checkPos(pos)
    shiftArray(BACKWARD, pos);
    length--;
    return true;
}