當前位置: 首頁>>代碼示例>>C++>>正文


C++ FindIndex函數代碼示例

本文整理匯總了C++中FindIndex函數的典型用法代碼示例。如果您正苦於以下問題:C++ FindIndex函數的具體用法?C++ FindIndex怎麽用?C++ FindIndex使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了FindIndex函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: FindIndex

/*=============================================================================
*NAME		:TYSIniFile::Delete
			:
*MODULE		:YSIniFiles.cpp
			:
*FUNCTION	:削除処理関數です
			:
*PROCESS	:・削除処理です。
			:
*INPUT		:const int index	:インデックス番號
			:
*PROGRAMMED	:Y.Sasai
*HISTORY	:
*ID -- DATE ------- NOTE ------------------------------------------------------
*00 03.02.10 Y.Sasai Ver.0.90 初期作成
*/
void TYSIniFile::Delete( const int index )
{
	TYSIniSection* ysection = (TYSIniSection*)GetAt( FindIndex( index ) );						// 2003.02.10 Y.Sasai Ver.0.90 iniセクションクラス取得

	delete( ysection );																			// 2003.02.10 Y.Sasai Ver.0.90 破棄だ
	RemoveAt( FindIndex( index ) );																// 2003.02.10 Y.Sasai Ver.0.90 削除だ
}
開發者ID:oht,項目名稱:VCLibrary,代碼行數:23,代碼來源:YSIniFiles.cpp

示例2: FindIndex

/*****************************************************************************
 * FindIndex: find the index of an object in an array of objects
 *****************************************************************************
 * This function assumes that p_this can be found in pp_objects. It will not
 * crash if p_this cannot be found, but will return a wrong value. It is your
 * duty to check the return value if you are not certain that the object could
 * be found for sure.
 *****************************************************************************/
static int FindIndex( vlc_object_t *p_this,
                      vlc_object_t **pp_objects, int i_count )
{
    int i_middle = i_count / 2;

    if( i_count == 0 )
    {
        return 0;
    }

    if( pp_objects[i_middle] == p_this )
    {
        return i_middle;
    }

    if( i_count == 1 )
    {
        return 0;
    }

    /* We take advantage of the sorted array */
    if( pp_objects[i_middle]->i_object_id < p_this->i_object_id )
    {
        return i_middle + FindIndex( p_this, pp_objects + i_middle,
                                             i_count - i_middle );
    }
    else
    {
        return FindIndex( p_this, pp_objects, i_middle );
    }
}
開發者ID:forthyen,項目名稱:SDesk,代碼行數:39,代碼來源:objects.c

示例3: FindIndex

size_t FindIndex(int *A, size_t n, int elem) {
    if (elem <= A[0])
        return 0;

    size_t first = 0, last = n, middle;
    while (first < last)  {
        middle = first + (last - first) / 2;

        if (elem <= A[middle])
            last = middle;
        else
            first = middle + 1;
    }

    if (middle == 0) {
        if (Abs(A[0] - elem) <= Abs(A[1] - elem))
            return 0;
        else
            return 1;
    }
    if (middle == n)
        return FindIndex(A, n, A[n-1]);
    if ( Abs(A[middle] - elem) >= Abs(A[middle-1] - elem) )
        return FindIndex(A, n, A[middle-1]);
    if (middle != n-1 && Abs(A[middle] - elem) > Abs(A[middle+1] - elem))
        return middle + 1;

    return middle;
}
開發者ID:Ksan0,項目名稱:AISD,代碼行數:29,代碼來源:main4_4.cpp

示例4: sprintf

//以普通方式寫一整數
bool Ini::Write(char *index, char *name, int num)
{
	//__ENTER_FUNCTION

	char string[32];
	sprintf(string, "%d", num);

	int n=FindIndex(index);
	if( n == -1 )	//新建索引
	{
		AddIndex(index);
		n=FindIndex(index);
		n=GotoLastLine(index);
		AddData(n, name, string);	//在當前位置n加一個數據
		return true;
	}

	//存在索引
	int m=FindData(n, name);
	if( m==-1 )		//新建數據
	{
		n=GotoLastLine(index);
		AddData(n, name, string);	//在當前位置n加一個數據
		return true;
	}

	//存在數據
	ModityData(n, name, string);	//修改一個數據

	return true;

	//__LEAVE_FUNCTION

//	return 0 ;
}
開發者ID:CrazyPro,項目名稱:ape,代碼行數:36,代碼來源:Ini.cpp

示例5: FindIndex

/*================================================================ 
* 函數名:    Write
* 參數:      [in] (char *index_name)當前索引名稱
*             [in] (char *key_name)KEY名稱
*             [in] (char *value_name)VALUE名稱
* 功能描述:   以普通方式寫一字符串數據
* 返回值:    成功則返回true, 否則返false
================================================================*/
bool CIni::Write(char *index_name, char *key_name, char *value_name)
{
	int data_pos = FindIndex(index_name);
	if (data_pos == ERROR_DATA_POS)	//新建索引
	{
		AddIndex(index_name);
		data_pos = FindIndex(index_name);
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, value_name);	//在當前位置n加一個數據
		return true;
	}

	//存在索引
	int data_pos2 = FindData(data_pos, key_name);
	if (data_pos2 == ERROR_DATA_POS)		//新建數據
	{
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, value_name);	//在當前位置n加一個數據
		return true;
	}

	//存在數據
	ModityData(data_pos, key_name, value_name);	//修改一個數據

	return true;
}
開發者ID:nykma,項目名稱:ykt4sungard,代碼行數:34,代碼來源:Ini.cpp

示例6: sprintf

/*================================================================ 
* 函數名:    Write
* 參數:      [in] (char *index_name)當前索引名稱
*             [in] (char *key_name)KEY名稱
*             [in] (int int_num)整型值
* 功能描述:   以普通方式寫一整數
* 返回值:    成功則返回true, 否則返false
================================================================*/
bool CIni::Write(char *index_name, char *key_name, int int_num)
{
	char string[32];
	sprintf(string, "%d", int_num);

	int data_pos = FindIndex(index_name);
	if (data_pos == ERROR_DATA_POS)	//新建索引
	{
		AddIndex(index_name);
		data_pos = FindIndex(index_name);
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, string);	//在當前位置n加一個數據
		return true;
	}

	//存在索引
	int data_pos2 = FindData(data_pos, key_name);
	if (data_pos2 == ERROR_DATA_POS)		//新建數據
	{
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, string);	//在當前位置n加一個數據
		return true;
	}

	//存在數據
	ModityData(data_pos, key_name, string);	//修改一個數據

	return true;
}
開發者ID:nykma,項目名稱:ykt4sungard,代碼行數:37,代碼來源:Ini.cpp

示例7: FindIndex

//搜索相同牌
bool CAndroidAIBase::SearchSameCard( BYTE byCardData,BYTE &byIndex1,BYTE &byIndex2 )
{
	//
	byIndex1 = FindIndex(byCardData);
	if( byIndex1 == 0xff ) return false;
	byIndex2 = FindIndex(byCardData,byIndex1+1);
	if( byIndex2 == 0xff ) return false;
	return true;
}
開發者ID:Michael-Z,項目名稱:qipai-game,代碼行數:10,代碼來源:AndroidAI.cpp

示例8: moments

void DetectFishDeth::update_data(vector<vector<Point>> contours)
{
    for (int i = 0; i < num_fish; ++i) {
        fish_Assigned[i] = 0;
    }
    // 沒有重疊的情況,目標數量==魚條數
    if (contours.size() == num_fish) {
        for (int i = 0; i < num_fish; ++i)
        {
            Moments m = moments(contours[i]);
            Point center = Point(m.m10 / m.m00, m.m01 / m.m00);

            //todo:
            //目標身份分配
            int index = FindIndex(center_point, center);

            trajectory[index].insert(trajectory[index].cbegin(), center);
            trajectory[index].pop_back();
            center_point[index] = center;

            nearest_point[index] = get_nearest_ponit(center, contours[i]);

            contour_area[index] = contourArea(contours[i]);
            //cout << index<<": "<<contour_area[index] << endl;
        }
    }
    //重疊的情況
    else if (contours.size() < num_fish) {

        sort(contours.begin(), contours.end(), [](vector<Point> a, vector<Point> b) {
            return contourArea(a) > contourArea(b);
        });

        for (int j = 0; j < contours.size(); ++j) {
            double n = round(contourArea(contours[j]) / avg_area);//重疊區域有幾個魚

            Moments m = moments(contours[j]);
            Point center = Point(m.m10 / m.m00, m.m01 / m.m00);

            for (int i = 0; i < n; ++i) {
                int index = FindIndex(center_point, center);
                trajectory[index].insert(trajectory[index].cbegin(), center);
                trajectory[index].pop_back();
                center_point[index] = center;
                contour_area[index] = contourArea(contours[j]) / n;

                if (n > 1) {
                    nearest_point[index] = -1;
                }
                else {
                    nearest_point[index] = get_nearest_ponit(center, contours[i]);
                }
            }
        }
    }
}
開發者ID:liyi1013,項目名稱:detect_fish_death_1,代碼行數:56,代碼來源:DetectFishDeth.cpp

示例9: LLOG

void TopWindow::EventProc(XWindow& w, XEvent *event)
{
	GuiLock __; 
	Ptr<Ctrl> this_ = this;
	if(event->type == ClientMessage) {
		if(event->xclient.format == 32 && event->xclient.message_type)
			if(event->xclient.message_type == XAtom("WM_PROTOCOLS")) {
				Atom a = event->xclient.data.l[0];
				if(a == XAtom("WM_DELETE_WINDOW") && IsEnabled()) {
					LLOG("DELETE_WINDOW " << Name());
					WhenClose();
					return;
				}
				if(a == XAtom("WM_TAKE_FOCUS")) {
					LLOG("TAKE_FOCUS serial: " << event->xclient.serial);
					Xeventtime = event->xclient.data.l[1];
					TakeFocus();
					return;
				}
				if(a == XAtom("_NET_WM_PING")) {
					XEvent ev = *event;
					ev.xclient.window = Xroot;
					XSendEvent(Xdisplay, Xroot, 0, SubstructureRedirectMask|SubstructureNotifyMask, &ev);
					return;
				}
				LLOG("Unknown WM_PROTOCOLS: " << XAtomName(a));
			}
	}
	else
	if(event->type == PropertyNotify && event->xproperty.atom == XAtom("_NET_WM_STATE")) {
		LLOG("_NET_WM_STATE notify");
		Vector<int> p = GetPropertyInts(GetWindow(), XAtom("_NET_WM_STATE"));
		if(FindIndex(p, (int)XAtom("_NET_WM_STATE_HIDDEN")) >= 0) {
			state = MINIMIZED;
			LLOG("MINIMIZED");
		}
		else
		if(FindIndex(p, (int)XAtom("_NET_WM_STATE_MAXIMIZED_HORZ")) >= 0 &&
		   FindIndex(p, (int)XAtom("_NET_WM_STATE_MAXIMIZED_VERT")) >= 0) {
			state = MAXIMIZED;
			LLOG("MAXIMIZED");
		}
		else {
			state = OVERLAPPED;
			LLOG("OVERLAPPED");
		}
	}
	if(this_) Ctrl::EventProc(w, event);
	if(this_) SyncSizeHints();
}
開發者ID:guowei8412,項目名稱:upp-mirror,代碼行數:50,代碼來源:X11Top.cpp

示例10: GetContinueDataNum

//返回連續的行數
int Ini::GetContinueDataNum(char *index)
{
	//__ENTER_FUNCTION

	int num=0;
	int n=FindIndex(index);
	n=GotoNextLine(n);
	while(1)
	{
		if( m_strData[n] == '\r' || m_strData[n] == EOF || m_strData[n] == -3 || m_strData[n] == ' ' || m_strData[n] == '/' || m_strData[n] == '\t' || m_strData[n] == '\n' )
		{
			return num;
		}
		else
		{
			num++;
			n=GotoNextLine(n);
			if( n >= m_lDataLen ) return num;
		}
	}

	//__LEAVE_FUNCTION

//	return 0 ;
}
開發者ID:CrazyPro,項目名稱:ape,代碼行數:26,代碼來源:Ini.cpp

示例11: GetItem

//*******************************************************************************
BOOL CBCGPDiagramVisualContainer::Remove (CBCGPDiagramItemID id, BOOL bRebuildContainer)
{
	CBCGPBaseVisualObject* pObject = GetItem (id);
	if (pObject == NULL)
	{
		return FALSE;
	}

	ASSERT_VALID(pObject);

	int nIndex = FindIndex (pObject);
	if (nIndex >= 0 && nIndex < (int) m_arObjects.GetSize ())
	{
		m_arObjects[nIndex] = NULL;
	}

	OnRemove (pObject);

	if (pObject->IsAutoDestroy ())
	{
		delete pObject;
	}

	if (bRebuildContainer)
	{
		RebuildContainer ();
	}

	AdjustLayout();
	return TRUE;
}
開發者ID:iclosure,項目名稱:jframework,代碼行數:32,代碼來源:BCGPDiagramVisualContainer.cpp

示例12: Point

XMLToolBarFrame &XMLToolBarFrame::DockAt(XMLToolBarCtrl &tb, Point p)
{
	// should not happen, but....
	if(FindIndex(tb) >= 0)
		return *this;
	
	// get dock position
	int dockLine, col;
	bool insert;
	if(!GetDockTarget(tb, p, dockLine, insert, col))
		return *this;

	// if needed, shift all positions to make place for this toolbar line
	if(insert)
	{
		for(int i = 0; i < relativePositions.GetCount(); i++)
			if(relativePositions[i].cy >= dockLine)
				relativePositions[i].cy++;
	}
		
	// docks the toolbar there
	relativePositions.Add(Size(col, dockLine));
	toolBars.Add(&tb);
	toolBarContainer.AddChild(&tb);
	Reposition();
	Layout();
	tb.toolBarPos = Point(relativePositions.Top().cx, relativePositions.Top().cy);
	return *this;
}
開發者ID:AbdelghaniDr,項目名稱:mirror,代碼行數:29,代碼來源:XMLToolBarFrame.cpp

示例13: FindIndex

// closes (undocking it) an XMLToolBar from this frame
XMLToolBarFrame &XMLToolBarFrame::Undock(XMLToolBarCtrl &tb)
{
	// if already docked here, just do nothing
	int i = FindIndex(tb);
	if(i < 0)
		return *this;

	// store inside toolbar last docked position
	Size &sz = relativePositions[i];
	toolBars[i]->toolBarPos= Point(sz.cx, sz.cy);
	
	// remove from toolbars and positions list
	toolBars.Remove(i);
	toolBarContainer.RemoveChild(&tb);
	relativePositions.Remove(i);
	
	// signals closed toolbar
	tb.toolBarState = TOOLBAR_CLOSED;
	tb.toolBarFrame = NULL;

	// reposition the frame
	Reposition();
	Layout();
	
	// frees toolbar from pointing here
	return *this;
}
開發者ID:AbdelghaniDr,項目名稱:mirror,代碼行數:28,代碼來源:XMLToolBarFrame.cpp

示例14: FindIndex

void
DBOptionsAttributes::SetEnumStrings(const std::string &name,
                                    const std::vector<std::string> &values)
{
    int eIndex = FindIndex(name);
    if (eIndex < 0)
        EXCEPTION0(BadDeclareFormatString);

    int numEnums = (int)optEnums.size();
    std::vector<std::string> newList;
    int idx = 0;
    for (int i = 0 ; i < numEnums ; i++)
    {
        if (i == eIndex)
        {
            for (size_t j = 0 ; j < values.size() ; j++)
                newList.push_back(values[j]);
        }
        else
        {
            for (int j = 0 ; j < enumStringsSizes[i] ; j++)
                newList.push_back(enumStrings[idx+j]);
        }
        idx += enumStringsSizes[i];
    }
    enumStrings = newList;
    enumStringsSizes[eIndex] = values.size();
}
開發者ID:robertmaynard,項目名稱:VisIt-Bridge,代碼行數:28,代碼來源:DBOptionsAttributes.C

示例15: FindIndex

int wxSheetArrayEdge::FindMaxEdgeIndex(int val, int edge_size) const
{
    const int index = FindIndex(val, true);
    if (index < 0) return -1;
    // we know we're inside the 'index' element (or above or below the array)
    //   find which side is closer and if < edge_size return index
    const int diff = abs(GetMax(index) - val);
    const int diff_min = (index > 0) ? abs(GetMax(index-1) - val) : diff+edge_size+1; 

    const int min_diff = wxMin(diff, diff_min);
    if (min_diff > edge_size)
        return -1;
    else if (min_diff == diff)
        return index;
    else if (min_diff == diff_min)
        return index - 1;
    
    return -1;
    
/*   
    // FIXME I wonder if this really makes complete sense? check it...
    // eg. what would happen if size of cell was only 1 pixel, you couldn't resize it?
    if ( GetSize(index) > edge_size )
    {
        // We know that we are in index, test whether we are
        // close enough to lower or upper border, respectively.
        if ( abs(GetMax(index) - val) < edge_size )
            return index;
        else if ( (index > 0) && (val - GetMin(index) < edge_size) )
            return index - 1;
    }

    return -1;
*/    
}
開發者ID:andrioni,項目名稱:gambit,代碼行數:35,代碼來源:sheetedg.cpp


注:本文中的FindIndex函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。