예제 #1
0
void AbstractTarget::AllocateArrays(int sizeX, int sizeY, int sizeZ, bool bWithIxyz)
{
	if ((sizeX != nx) || (sizeY != ny) || (sizeZ != nz))
	{
		int del = Analyze(sizeX);
		if (del > 0) maxJx += del;
		nx = sizeX;
		del = Analyze(sizeY);
		if (del > 0) maxJy += del;
		ny = sizeY;
		del = Analyze(sizeZ);
		if (del > 0) maxJz += del;
		nz = sizeZ;
		nat = nx * ny * nz;
		iocc = (bool *)realloc(iocc, nat * sizeof(bool));
		memset(iocc, 0, nat * sizeof(bool));
		icomp.Deallocate();
		icomp.Dimension(nat, 3);
		icomp.Clear();
		if (bWithIxyz)
		{
			ixyz.Deallocate();
			ixyz.Dimension(nat, 3);
			ixyz.Clear();
		}
	}
}
예제 #2
0
bool DependenciesAnalyzer::Analyze()
{
    if (layout)
        return Analyze(layout->GetEvents(), true);
    else if (externalEvents)
        return Analyze(externalEvents->GetEvents(), true);

    std::cout << "ERROR: DependenciesAnalyzer called without any layout or external events.";
    return false;
}
예제 #3
0
	bool Analyze(int aKindPai[], int zipai)
	{
		if (aKindPai[0] == 0) {

			return true;	
		}

		//寻找第一张字牌
		int j = 1;
		for (j = 1; j < 10; j ++) {

			if (aKindPai[j] != 0) 
				break;
		}

		bool result;
		if (aKindPai[j] >= 3)	//作为壳子
		{
			aKindPai[j] -= 3;
			aKindPai[0] -= 3;
			result = Analyze(aKindPai, zipai);
			//还原这三张
			aKindPai[j] += 3;
			aKindPai[0] +=3;
			return result;
		}

		//作为顺牌
		if ((!zipai) && (j < 8) 
			&& (aKindPai[j+1] > 0)
			&& (aKindPai[j+2]) > 0)
		{
			//除去这三张
			aKindPai[j] --;
			aKindPai[j+1] --;
			aKindPai[j+2] --;
			aKindPai[0] -= 3;
			result = Analyze(aKindPai, zipai);
			//还原这三张顺子
			aKindPai[j] ++;
			aKindPai[j+1] ++;
			aKindPai[j+2] ++;
			aKindPai[0] += 3;
			return result;
		}

		return false;
	}
예제 #4
0
int CAPETag::SetFieldBinary(const str_utf16 * pFieldName, const void * pFieldValue, int nFieldBytes, int nFieldFlags)
{
    if (m_bAnalyzed == FALSE) { Analyze(); }
    if (pFieldName == NULL) return -1;

    // check to see if we're trying to remove the field (by setting it to NULL or an empty string)
    BOOL bRemoving = (pFieldValue == NULL) || (nFieldBytes <= 0);

    // get the index
    int nFieldIndex = GetTagFieldIndex(pFieldName);
    if (nFieldIndex != -1)
    {
        // existing field

        // fail if we're read-only (and not ignoring the read-only flag)
        if ((m_bIgnoreReadOnly == FALSE) && (m_aryFields[nFieldIndex]->GetIsReadOnly()))
            return -1;
        
        // erase the existing field
        SAFE_DELETE(m_aryFields[nFieldIndex])

        if (bRemoving)
        {
            return RemoveField(nFieldIndex);
        }
    }
    else
    {
        if (bRemoving)
예제 #5
0
BOOL CARIB8CharDecode::Caption( const BYTE* pbSrc, DWORD dwSrcSize, vector<CAPTION_DATA>* pCaptionList )
{
	if( pbSrc == NULL || dwSrcSize == 0 || pCaptionList == NULL){
		return FALSE;
	}
	InitCaption();
	m_pCaptionList = pCaptionList;

	BOOL bRet = TRUE;
	DWORD dwReadCount = 0;
	while(dwReadCount<dwSrcSize){
		DWORD dwReadSize = 0;
		BOOL bRet = Analyze(pbSrc+dwReadCount, dwSrcSize-dwReadCount, &dwReadSize );
		if( bRet == TRUE ){
			if( m_strDecode.size() > 0 ){
				CheckModify();
			}
		}else{
			pCaptionList->clear();
			break;
		}
		m_strDecode = "";
		dwReadCount+=dwReadSize;
	}
	return bRet;
}
예제 #6
0
BOOL CThhylDlg::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	const WORD notifycode = HIWORD(wParam);
	const WORD id         = LOWORD(wParam);

	if (id == IDC_RPYFILE) { // “录像文件”编辑框
		if (notifycode == EN_KILLFOCUS) {
			// 焦点离开编辑框时不接受用户在编辑框中输入的路径,除非用户按了回车。
			UpdateData(FALSE);
			return TRUE;
		}
	}

	// menu commands and others
	switch(id)
	{
	case IDM_CHANGEENCODESTART+0: cfg.InfoCode = 932; break;
	case IDM_CHANGEENCODESTART+1: cfg.InfoCode = 936; break;
	case IDM_CHANGEENCODESTART+2: cfg.InfoCode = 950; break;
	case IDM_CHANGEENCODESTART+3: cfg.InfoCode = 0; break;
	default: return CDlgBaseWZ::OnCommand(wParam, lParam);
	}
	
	cfg.CommentCode = cfg.InfoCode;
	if(m_filestatus.IsValid())
		Analyze();
	return TRUE;
}
예제 #7
0
void CThhylDlg::OnEditcomment() 
{
	// TODO: Add your control notification handler code here
	if (!(m_bTHX && m_filestatus.IsValid())) {
		const HWND hRpyFile = ((CButton*)GetDlgItem(IDC_RPYFILE))->GetSafeHwnd();
		LPCTSTR const msgtitle = _T("无法编辑注释。可能的原因:");
		LPCTSTR const msg = _T("1. 红魔乡和妖妖梦的录像文件无法添加注释;\n")
							_T("2. 尚未打开任何文件或文件格式不支持。");
		const HICON icon = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME));

		if (!ShowBalloonMsg( hRpyFile, msg, msgtitle, TTI_WARNING, FALSE, icon)) {
			// 如果 balloon 不支持,则显示 msgbox
			UserIconedMsgBox(msg, 0, MB_ICONEXCLAMATION, msgtitle);
		}
	}
	else {
		CDlgComment dlg;
		dlg.m_pCommentData = &m_strCurrComment;
		dlg.m_filename = m_rpyfile;
		dlg.m_pRpyData = m_pRpyData;
		dlg.m_dwRpySize = m_dwRpySize;
		if (dlg.DoModal()==IDOK)
			Analyze();
		
		cfg.CommentCodeForEdit = dlg.m_CommentCodeEdit;
	}
}
예제 #8
0
void CThhylDlg::OnOption() 
{
	// TODO: Add your control notification handler code here
	CDlgOption dlg;
	if (IDOK == dlg.DoModal() && m_filestatus.IsValid())
		Analyze();
}
예제 #9
0
void CThhylDlg::CopyOrMoveRpy(LPCTSTR DialogTitle, BOOL bCopy)
{
	if (!m_filestatus.IsValid())
		return;
	
	CString filter((LPCTSTR)IDS_DLGFILTER), newfilename;
	
	CFileDialogWZ dlg(FALSE, _T("rpy"), m_rpyfile,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
		filter, this);
	dlg.m_ofn.lpstrTitle=DialogTitle;
	if (dlg.DoModal()==IDCANCEL)
		return;
	
	newfilename=dlg.GetPathName();
	
	BOOL result;
	result = bCopy
		? CopyFile(m_rpyfile, newfilename, FALSE)
		: MoveFileEx(m_rpyfile, newfilename, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);

	if (result) { //复制/移动成功
		//如果是移动,或者在选项中选中了“打开复制后的目标文件”
		if (!bCopy || HasConfigOption(CFG_COPYOPENDEST)) {
			m_rpyfile = newfilename;
			Analyze();
		}
	}
	else {
		LPCTSTR ErrorMsg;
		ErrorMsg = GetErrorMessage(GetLastError());
		MessageBox( ErrorMsg, DialogTitle, MB_ICONSTOP );
	}
}
예제 #10
0
int CAPETag::GetFieldBinary(const str_utf16 * pFieldName, void * pBuffer, int * pBufferBytes)
{
    if (m_bAnalyzed == FALSE) { Analyze(); }
    
    int nRetVal = ERROR_UNDEFINED;

    if (*pBufferBytes > 0)
    {
        CAPETagField * pAPETagField = GetTagField(pFieldName);
        if (pAPETagField == NULL)
        {
            memset(pBuffer, 0, *pBufferBytes);
            *pBufferBytes = 0;
        }
        else
        {
            if (pAPETagField->GetFieldValueSize() > *pBufferBytes)
            {
                // we'll fail here, because partial data may be worse than no data
                memset(pBuffer, 0, *pBufferBytes);
                *pBufferBytes = pAPETagField->GetFieldValueSize();
            }
            else
            {
                // memcpy
                *pBufferBytes = pAPETagField->GetFieldValueSize();
                memcpy(pBuffer, pAPETagField->GetFieldValue(), *pBufferBytes);
                nRetVal = ERROR_SUCCESS;
            }
        }
    }

    return nRetVal;
}
예제 #11
0
void CThhylDlg::OnBrowse() 
{
	// TODO: Add your control notification handler code here
	CString filter((LPCTSTR)IDS_DLGFILTER);
	
	CFileDialogWZ dlg(TRUE, NULL, NULL,
		OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT,
		filter, this);
	TCHAR filebuf[32768] = {0};

	dlg.m_ofn.lpstrFile  = filebuf;
	dlg.m_ofn.nMaxFile   = lengthof(filebuf);
	dlg.m_ofn.lpstrTitle = _T("打开录像文件");
	if (dlg.DoModal() == IDOK) {
		BOOL bFirstFile = TRUE;
		CString strFilePath;
		POSITION pos = dlg.GetStartPosition();

		while (pos) {
			strFilePath = dlg.GetNextPathName(pos);

			if (bFirstFile) {
				UpdateData(TRUE);
				m_rpyfile = strFilePath;
				UpdateData(FALSE);
				Analyze();
				bFirstFile = FALSE;
			}
			else {
				SpawnInstance(strFilePath);
			}
		}
	}
}
예제 #12
0
void CThhylDlg::OnDropFiles(HDROP hDropInfo) 
{
	// TODO: Add your message handler code here and/or call default
	const UINT nFileCount = ::DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, _MAX_PATH);
	LPTSTR const lpszFileName = new TCHAR[_MAX_PATH];

	for (UINT i=0; i<nFileCount; ++i) {
		::DragQueryFile(hDropInfo, i, lpszFileName,_MAX_PATH);

		if (i==0) { // 第1个文件
			UpdateData(TRUE);
			m_rpyfile = lpszFileName;
			ConvToFullPath();
			UpdateData(FALSE);
		} else //如果拖入了2个或2个以上的文件,则另开一个自身的实例来打开。
			SpawnInstance(lpszFileName);
	}
		
	::DragFinish(hDropInfo);
	delete []lpszFileName;
	
	if (nFileCount > 0) Analyze();

	//CDlgBaseWZ::OnDropFiles(hDropInfo);
}
예제 #13
0
void CThhylDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
	CDlgBaseWZ::OnActivate(nState, pWndOther, bMinimized);
	
	// TODO: Add your message handler code here
	// TRACE1("thhylDlg OnActivate %d", nState == WA_ACTIVE || nState == WA_CLICKACTIVE);
	if (nState == WA_ACTIVE || nState == WA_CLICKACTIVE) {
		if (m_bNeedReanalyze && m_filestatus.IsValid()) {
			CFileStatusWZ newfilestatus;

			m_bNeedReanalyze = FALSE;
			if (CFile::GetStatus(m_filestatus.m_szFullName, newfilestatus)) {
				// file still exists, Re-analyze if the file has been modified
				if ( !newfilestatus.IsSameDateAndSize(m_filestatus) ) {
					Analyze();
				}
				m_filestatus.Update(newfilestatus);
			}
			else {
				// file does not exist or cannot be opened, close it.
				if (HasConfigOption(CFG_AUTOEXIT))
					OnCancel();
				else
					CloseFile();
			}
		}
	}
}
예제 #14
0
void Detection::WorkFunc()
{
    CheckIP138();
    CheckIP();
    TestTinydrag();
    Ping();
    GetLocalIP();
    Test9KAPPPAC();
    Test9K();
    Test8888();
    boost::thread work_thread(boost::bind(&Detection::TestTracker, this));
    for (int i = 0; i < 5 * 60; ++i)
    {
        if (i % 3 == 0)
        {
            ++m_progress_pos_;
            if (i % 60 == 0)
            {
                Test9K();
            }
        }
        Sleep(1000);
    }
    Analyze();
    TestBs();
    Test9K();
    WriteTrackerResult();
    Sleep(1000);
    MessageBox("测试完毕!");
}
예제 #15
0
double EffectTruncSilence::CalcPreviewInputLength(double /* previewLength */)
{
   double inputLength = mT1 - mT0;
   double minInputLength = inputLength;

   // Master list of silent regions
   RegionList silences;

   // Start with the whole selection silent
   silences.push_back(Region(mT0, mT1));

   SelectedTrackListOfKindIterator iter(Track::Wave, mTracks);
   int whichTrack = 0;

   for (Track *t = iter.First(); t; t = iter.Next()) {
      WaveTrack *const wt = static_cast<WaveTrack *>(t);

      RegionList trackSilences;

      sampleCount index = wt->TimeToLongSamples(mT0);
      sampleCount silentFrame = 0; // length of the current silence

      Analyze(silences, trackSilences, wt, &silentFrame, &index, whichTrack, &inputLength, &minInputLength);

      whichTrack++;
   }
   return inputLength;
}
예제 #16
0
파일: terrain.cpp 프로젝트: cs580project/RL
void Terrain::IncTerrainAnalysis( void )
{
	m_reevaluateAnalysis = true;
	m_analysis = (TerrainAnalysisType)((int)m_analysis + 1);
	if(TerrainAnalysis_Count == g_terrain.m_analysis) { g_terrain.m_analysis = TerrainAnalysis_None; }
	ClearTerrainAnalysis();
	Analyze();
}
예제 #17
0
void IndexTuner::IndexTuneHelper(storage::DataTable* table) {

  // Add required indices
  Analyze(table);

  // Build desired indices
  BuildIndices(table);
}
예제 #18
0
void Sudoku::ReadIn()
{
	status = UNDETERMINED;

	for (int i = 0; i < 81; i++)
		scanf("%d", &table[i]);

	Analyze();
}
예제 #19
0
bool EffectTruncSilence::FindSilences
   (RegionList &silences, Track *firstTrack, Track *lastTrack)
{
   // Start with the whole selection silent
   Region *sel = new Region;
   sel->start = mT0;
   sel->end = mT1;
   silences.push_back(sel);

   // Remove non-silent regions in each track
   SelectedTrackListOfKindIterator iter(Track::Wave, mTracks);
   int whichTrack = 0;
   bool lastSeen = false;
   for (Track *t = iter.StartWith(firstTrack); !lastSeen && t; t = iter.Next())
   {
      lastSeen = (t == lastTrack);
      WaveTrack *const wt = static_cast<WaveTrack *>(t);

      // Smallest silent region to detect in frames
      sampleCount minSilenceFrames =
         sampleCount(std::max(mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());

      //
      // Scan the track for silences
      //
      RegionList trackSilences;
      trackSilences.DeleteContents(true);

      sampleCount index = wt->TimeToLongSamples(mT0);
      sampleCount silentFrame = 0;

      // Detect silences
      bool cancelled = !(Analyze(silences, trackSilences, wt, &silentFrame, &index, whichTrack));

      // Buffer has been freed, so we're OK to return if cancelled
      if (cancelled)
      {
         ReplaceProcessedTracks(false);
         return false;
      }

      if (silentFrame >= minSilenceFrames)
      {
         // Track ended in silence -- record region
         Region *r = new Region;
         r->start = wt->LongSamplesToTime(index - silentFrame);
         r->end = wt->LongSamplesToTime(index);
         trackSilences.push_back(r);
      }

      // Intersect with the overall silent region list
      Intersect(silences, trackSilences);
      whichTrack++;
   }

   return true;
}
예제 #20
0
CAPETagField * CAPETag::GetTagField(int nIndex)
{
    if (m_bAnalyzed == FALSE) { Analyze(); }

    if ((nIndex >= 0) && (nIndex < m_nFields))
    {
        return m_aryFields[nIndex];
    }

    return NULL;
}
예제 #21
0
int CAPETag::GetFieldString(const str_utf16 * pFieldName, str_utf16 * pBuffer, int * pBufferCharacters)
{
    if (m_bAnalyzed == FALSE) { Analyze(); }

    int nRetVal = ERROR_UNDEFINED;

    if (*pBufferCharacters > 0)
    {
        CAPETagField * pAPETagField = GetTagField(pFieldName);
        if (pAPETagField == NULL)
        {
            // the field doesn't exist -- return an empty string
            memset(pBuffer, 0, *pBufferCharacters * sizeof(str_utf16));
            *pBufferCharacters = 0;
        }
        else if (pAPETagField->GetIsUTF8Text() || (m_nAPETagVersion < 2000))
        {
            // get the value in UTF-16 format
            CSmartPtr<str_utf16> spUTF16;
            if (m_nAPETagVersion >= 2000)
                spUTF16.Assign(GetUTF16FromUTF8((str_utf8 *) pAPETagField->GetFieldValue()), TRUE);
            else
                spUTF16.Assign(GetUTF16FromANSI(pAPETagField->GetFieldValue()), TRUE);

            // get the number of characters
            int nCharacters = (wcslen(spUTF16) + 1);
            if (nCharacters > *pBufferCharacters)
            {
                // we'll fail here, because it's not clear what would get returned (null termination, size, etc.)
                // and we really don't want to cause buffer overruns on the client side
                *pBufferCharacters = nCharacters;
            }
            else
            {
                // just copy in
                *pBufferCharacters = nCharacters;
                memcpy(pBuffer, spUTF16.GetPtr(), *pBufferCharacters * sizeof(str_utf16));
                nRetVal = ERROR_SUCCESS;
            }
        }
        else
        {
            // memset the whole buffer to NULL (so everything left over is NULL terminated)
            memset(pBuffer, 0, *pBufferCharacters * sizeof(str_utf16));

            // do a binary dump (need to convert from wchar's to bytes)
            int nBufferBytes = (*pBufferCharacters - 1) * sizeof(str_utf16);
            nRetVal = GetFieldBinary(pFieldName, pBuffer, &nBufferBytes);
            *pBufferCharacters = (nBufferBytes / sizeof(str_utf16)) + 1;
        }
    }

    return nRetVal;
}
예제 #22
0
void Sudoku::GiveQuestion()
{
	srand(time(NULL));

	const int *pTemplate = sudoku_template[rand() % cnt_template];
	int question[81], trans[10] = { 0 };

	/// random
	for (int i = 1; i <= 9; i++)
	{
		int num;

		do
		{
			num = rand() % 9 + 1;
		}while(trans[num]);

		trans[num] = i;
	}
	/// fill
	for (int i = 0; i < 81; i++)
		question[i] = trans[pTemplate[i]];
	/// dig
	for (int c = 0; c < 55; c++)
	{
		int pos;

		memcpy(table, question, sizeof(table));
		do
		{
			pos = rand() % 81;
		} while(table[pos] == EMPTY_CELL);

		table[pos] = EMPTY_CELL;

		Init();
		Analyze();
		backtracking(0);

		if (status == ONE_SOULUTION)
			memcpy(question, table, sizeof(question));
	}

	/*for (int i = 0; i < 9; i++)
	{
		for (int k = 0; k < 9; k++)
		{
			if (!k) printf("%d", question[i*9+k]);
			else printf(" %d", question[i*9+k]);
		}
		putchar('\n');
	}*/
}
	void TextureAtlasPatternFileLoader::Load( int archiveHandle, const std::string& filePath )
	{
		// アーカイブからファイルを読み込む
		int size = MAPIL::GetContentsSizeOnArchiveFile( archiveHandle, filePath.c_str() );
		char* pBuf = new char [ size ];
		MAPIL::LoadDataFromArchiveFile( archiveHandle, filePath.c_str(), pBuf );

		// ファイル解析
		Analyze( pBuf, size );

		MAPIL::SafeDeleteArray( pBuf );
	}
예제 #24
0
파일: terrain.cpp 프로젝트: cs580project/RL
void Terrain::DrawDebugVisualization( IDirect3DDevice9* pd3dDevice )
{
	D3DXVECTOR3 pos( 0.0f, 0.001f, 0.0f );

	for( int r=0; r<m_width; r++ )
	{
		for( int c=0; c<m_width; c++ )
		{
			pos.x = (float)c / m_width;
			pos.z = (float)r / m_width;

			switch (m_terrain[r][c])
			{
			case TILE_WALL:
				g_debugdrawing.DrawCube( pd3dDevice, &pos, 0.8f/m_width, DEBUG_COLOR_BLACK );
				break;
			case TILE_EMPTY:
				g_debugdrawing.DrawQuad( pd3dDevice, &pos, 1.0f/m_width, m_terrainColor[r][c] );
				break;
			case TILE_WALL_INVISIBLE:
				g_debugdrawing.DrawCube( pd3dDevice, &pos, 1.f/m_width, DEBUG_COLOR_GRAY );
				break;
			default:
				assert("Invalid tile type");
			}
		}
	}

	if(m_analysis == TerrainAnalysis_Search)
	{	//Discount search tiles
		m_reevaluateAnalysis = true;
		for( int r=0; r<m_width; r++ )
		{
			for( int c=0; c<m_width; c++ )
			{
				m_terrainInfluenceMap[r][c] *= 0.999f;
			}
		}
	}

	pos.y = 0.002f;
	Analyze();
	for( int r=0; r<m_width; r++ )
	{
		for( int c=0; c<m_width; c++ )
		{
			pos.x = (float)c / m_width;
			pos.z = (float)r / m_width;
			D3DXCOLOR color = D3DXCOLOR( 1.0f, 0.0f, 0.0f, m_terrainInfluenceMap[r][c] );
			g_debugdrawing.DrawQuad( pd3dDevice, &pos, 1.0f/m_width, color );
		}
	}
}
예제 #25
0
CAPETag::CAPETag(CIO * pIO, BOOL bAnalyze)
{
    m_spIO.Assign(pIO, FALSE, FALSE); // we don't own the IO source
    m_bAnalyzed = FALSE;
    m_nFields = 0;
    m_nTagBytes = 0;
    
    if (bAnalyze)
    {
        Analyze();
    }
}
예제 #26
0
void CThhylDlg::OnOK() 
{
	// TODO: Add extra validation here
	if (GetDlgItem(IDC_RPYFILE)!=GetFocus())
		return;

	UpdateData(TRUE);
	ConvToFullPath();
	UpdateData(FALSE);
	Analyze();

	//CDlgBaseWZ::OnOK();
}
예제 #27
0
파일: pmproc.cpp 프로젝트: gitgun/dLabPro
//{{CGEN_PMIC
INT16 CPMproc::OnAnalyze()
/* DO NOT CALL THIS FUNCTION FROM C++ SCOPE.     */
/* IT MAY INTERFERE WITH THE INTERPRETER SESSION */
{
    INT16 __nErr    = O_K;
    INT32  __nErrCnt = 0;
    MIC_CHECK;
    __nErrCnt = CDlpObject_GetErrorCount();
    data* idPitch = MIC_GET_I_EX(idPitch,data,1,1);
    data* idSignal = MIC_GET_I_EX(idSignal,data,2,2);
    if (CDlpObject_GetErrorCount()>__nErrCnt) return NOT_EXEC;
    __nErr = Analyze(idSignal, idPitch);
    return __nErr;
}
예제 #28
0
int CAPETag::GetTagFieldIndex(const str_utf16 * pFieldName)
{
    if (m_bAnalyzed == FALSE) { Analyze(); }
    if (pFieldName == NULL) return -1;

    for (int z = 0; z < m_nFields; z++)
    {
        if (wcsicmp(m_aryFields[z]->GetFieldName(), pFieldName) == 0)
            return z;
    }

    return -1;

}
예제 #29
0
std::list<GraphEdge*> Graph::Analyze(int i)
{
	std::list<GraphEdge*> ret;
	LOG(TRACE) << "Checking node " << i << " for possible lock";
	auto freeEdges = std::count_if(adjacencyVector[i].begin(), adjacencyVector[i].end(), [](EdgeRef& e) {return !std::get<1>(e); });
	if(freeEdges == 1)
	{
		auto edge = std::find_if(adjacencyVector[i].begin(), adjacencyVector[i].end(), [](EdgeRef& e) {return !std::get<1>(e); });
		LockEdge(i, std::get<0>(*edge));
		LOG(TRACE) << "Adding to history edge from " << i << " to " << std::get<0>(*edge);
		ret.splice(ret.end(), Analyze(std::get<0>(*edge)));
		ret.push_back(new GraphEdge(i, std::get<0>(*edge), std::get<2>(*edge)));
	}
	return ret;
}
예제 #30
0
bool Graph::CutEdge(int from, int to)
{
	LOG(TRACE) << "Cutting GraphEdge " << from << "-" << to;
	if (!AreConnected(from, to))
	{
		LOG(WARNING) << "No such edge";
		return false;
	}
	auto a = std::find_if(adjacencyVector[from].begin(), adjacencyVector[from].end(), [to](const EdgeRef& e) {return std::get<0>(e) == to; });
	if (std::get<1>(*a))
	{
		LOG(WARNING) << "Edge cannot be cut, state is " << std::get<1>(*a);
		return false;
	}
	std::get<1>(*a) = Deleted;
	auto b = std::find_if(adjacencyVector[to].begin(), adjacencyVector[to].end(), [from](const EdgeRef& e) {return std::get<0>(e) == from; });
	std::get<1>(*b) = Deleted;
	LOG(TRACE) << "Adding to history edge from " << from << " to " << to;
	std::list<GraphEdge*> step = Analyze(from);
	step.splice(step.end(), Analyze(to));
	step.push_front(new GraphEdge(from, to, std::get<2>(*a)));
	history.push(step);
	return true;
}