示例#1
0
void puzzle_g()
{
    Blocks bs;
    Board board(6, 5);

    bs.push_back(&(*(new Block()))("***|*"));
    bs.push_back(&(*(new Block()))("****"));
    bs.push_back(&(*(new Block()))(" *|**|*"));
    bs.push_back(&(*(new Block()))("*|**"));
    bs.push_back(&(*(new Block()))("***"));
    bs.push_back(&(*(new Block()))("**|**"));
    bs.push_back(&(*(new Block()))("*|*"));
    bs.push_back(&(*(new Block()))("  *|* *|***"));

    cout << "---------- Puzzle G ----------" << endl;

    if (!board.Unblock(bs))
    {
        cout << "No solution!" << endl;
    }

    for (auto i = bs.cbegin(); i != bs.cend(); i++)
    {
        delete (*i);
    }
}
示例#2
0
static bool addBranchBlock(Blocks &blocks, Block &block,
                           const Instruction &branchDestination,
                           Block *&branchBlock, BlockEdgeType type) {

	/* Prepare to follow one branch of the path.
	   Returns true if this is a completely new path we haven't handled yet.
	   branchBlock will be filled with the block for the branch. */

	bool needAdd = false;

	// See if we have already handled this branch. If not, create a new block for it.
	branchBlock = const_cast<Block *>(branchDestination.block);
	if (!branchBlock) {
		blocks.push_back(Block(branchDestination.address));

		branchBlock = &blocks.back();
		needAdd     = true;
	}

	// Link the branch with its parent

	branchBlock->parents.push_back(&block);
	block.children.push_back(branchBlock);

	block.childrenTypes.push_back(type);

	return needAdd;
}
示例#3
0
	void MarkBlockUsed( const SBlock& p_Block, unsigned int p_unWidth, unsigned int p_unHeight )
	{
		m_unFirstX += p_unWidth;
		if( m_unFirstX + p_unWidth >= m_unWidth )
		{
			m_unFirstX = 0;
			m_unFirstY += p_unHeight;
		}
		m_vecBlocks.push_back( p_Block );
	}
示例#4
0
void constructBlocks(Blocks &blocks, Instructions &instructions) {
	/* Create the first block containing the very first instruction in this script.
	 * Then follow the complete code flow from this instruction onwards. */

	assert(blocks.empty());
	if (instructions.empty())
		return;

	blocks.push_back(Block(instructions.front().address));
	constructBlocks(blocks, blocks.back(), instructions.front());
}
示例#5
0
文件: PatchMgr.C 项目: Zirkon/dyninst
void PatchMgr::getBlocks(Scope &scope, Blocks &blocks) {
   if (scope.wholeProgram) {
      const AddrSpace::ObjMap &objs = as()->objMap();
      for (AddrSpace::ObjMap::const_iterator iter = objs.begin(); iter != objs.end(); ++iter) {
         iter->second->blocks(std::back_inserter(blocks));
      }
   }
   else if (scope.obj) {
      scope.obj->blocks(std::back_inserter(blocks));
   }
   else if (scope.block) {
      blocks.push_back(scope.block);
   }
}
示例#6
0
 void addBlock(Block block) {
     blocks.push_back(block);
 }