• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ FindIndex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了FindIndex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: FindIndex

void SortedVectorMapRow<V>::ApplyIncUnsafe(int32_t column_id,
    const void *update) {
  // Go through the array and find column_id
  int32_t vector_idx = FindIndex(column_id);
  V typed_update = *(reinterpret_cast<const V*>(update));
  if (vector_idx != -1) {
    entries_[vector_idx].second += typed_update;

    // Remove vector_idx if vector_idx becomes 0.
    if (entries_[vector_idx].second == V(0)) {
      RemoveOneEntryAndCompact(vector_idx);
      return;
    }

    // Move vector_idx to maintain sorted order.
    bool forward = typed_update <= V(0);
    LinearSearchAndMove(vector_idx, forward);
    return;
  }
  // Add a new entry.
  if (num_entries_ == capacity_) {
    ResetCapacity(capacity_ + K_BLOCK_SIZE_);
  }

  entries_[num_entries_].first = column_id;
  entries_[num_entries_].second = typed_update;
  ++num_entries_;
  // Move new entry to maintain sorted order. Always move backward.
  LinearSearchAndMove(num_entries_ - 1, false);
}
开发者ID:Nikraaaazy,项目名称:bosen,代码行数:30,代码来源:sorted_vector_map_row.hpp


示例17: memset

//在指定的行读一数据名称
char *Ini::ReadCaption(char *index, int lines, char* str, int size)
{
	//__ENTER_FUNCTION

	char szTmp[512] ;
	memset( szTmp, 0, 512 ) ;
	sprintf( szTmp, "[%s][%s][%d]", m_strFileName, index, lines ) ;

	int n=FindIndex(index);
	//AssertEx( n != -1, szTmp );

	//跳到指定行数
	n=GotoNextLine(n);
	for(int i=0; i<lines; i++)
	{
		if( n<m_lDataLen )
			n=GotoNextLine(n);
	}

	char* ret = ReadDataName(n);
	strncpy( str, ret, size ) ;
	return ret ;

	//__LEAVE_FUNCTION

//	return 0 ;
}
开发者ID:CrazyPro,项目名称:ape,代码行数:28,代码来源:Ini.cpp


示例18: CloseNodes_Add

int 
CloseNodes_Add(CloseNodes *close, Node *node)
{
    assert(close != NULL && "NULL CloseNodes pointer");
    assert(node != NULL && "NULL Node pointer");

    Distance distance = Hash_Distance(&close->id, &node->id);
    int i = FindIndex(close->close_nodes, &distance);

    if (i < 0)
        return 0;

    struct CloseNode *close_node = malloc(sizeof(struct CloseNode));
    check_mem(close_node);

    close_node->node = node;
    close_node->distance = distance;

    if (DArray_count(close->close_nodes) < BUCKET_K)
        DArray_push(close->close_nodes, NULL);

    ShiftFrom(close->close_nodes, i);
    DArray_set(close->close_nodes, i, close_node);

    return 0;
error:
    return -1;
}
开发者ID:polysome,项目名称:amok,代码行数:28,代码来源:close.c


示例19: FindLeadIndexReco

void FindLeadIndexReco( int algo, int &lead, int &sec) {

  float eta, phi;

  // calculate dR of all the jets w.r.t. the two electrons
  for( int j=0; j < NumRecoJets; j++ ) {

    if(usingCorrectedCaloJetPt) {
      p[j]  = JetCorPt[algo][j];
      eta = JetCorEta[algo][j];
      phi = JetCorPhi[algo][j];
    }
    else {
      p[j]  = JetRecoPt[algo][j];
      eta = JetRecoEta[algo][j];
      phi = JetRecoPhi[algo][j];
    }

    // protection:
    if( p[j] < 0.001 ) { p[j] = 0.001; break; }

    R1[j] = radius( eta, phi, eMinusEta,  eMinusPhi );
    R2[j] = radius( eta, phi, ePlusEta,  ePlusPhi );
   }
  
  FindIndex( p, R1, R2, lead, sec, NumRecoJets );
}
开发者ID:ajaykumar649,项目名称:scripts,代码行数:27,代码来源:plot_ZJetBalance.C


示例20: GetStr

void CIni::GetStr(const char* pszIndex, const char* pszKey,
			const char* pszDefault,
			char* szBuf, int nBufLen)
{
	if( pszIndex==NULL||pszKey==NULL|| pszDefault==NULL
		||szBuf==NULL||nBufLen<=0) return ;


	int nIndexPos = 0;
	int nKeyPos = 0;
	int nRet= 0 ;
	char szValueBuf[MAX_VALUE_BUF_LEN]={0};
	 if( (nIndexPos =FindIndex(pszIndex))!=-1)
	 {
		 if( (nKeyPos = FindKey(pszKey, nIndexPos))!=-1)
		 {
			if(GetValue(nKeyPos,szValueBuf,MAX_VALUE_BUF_LEN))
			{
				if(strlen(szValueBuf)<=nBufLen)
					strcpy(szBuf, szValueBuf);
				return;
			}
			
		 }
	 }
	if(strlen(pszDefault)<=nBufLen)
		strcpy(szBuf, pszDefault);
	else
		strcpy(szBuf,"");
}
开发者ID:eickegao,项目名称:avgscript,代码行数:30,代码来源:Ini.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FindItem函数代码示例发布时间:2022-05-30
下一篇:
C++ FindInReadable函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap