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


C++ Contains函數代碼示例

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


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

示例1: Intersects

/* Intersects
 * test for a common area between segment and rect.
 * return true if at least a common point is found
 */
bool EDA_RECT::Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2 ) const
{
    wxPoint point2, point4;

    if( Contains( aPoint1 ) || Contains( aPoint2 ) )
        return true;

    point2.x = GetEnd().x;
    point2.y = GetOrigin().y;
    point4.x = GetOrigin().x;
    point4.y = GetEnd().y;

    //Only need to test 3 sides since a straight line cant enter and exit on same side
    if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin() , point2 ) )
        return true;

    if( SegmentIntersectsSegment( aPoint1, aPoint2, point2      , GetEnd() ) )
        return true;

    if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd()    , point4 ) )
        return true;

    return false;
}
開發者ID:OpenEE,項目名稱:micad,代碼行數:28,代碼來源:base_struct.cpp

示例2: if

Widget *Container::GetWidgetAt(const Point &pos)
{
	if (!Contains(pos)) return 0;

	for (RefCountedPtr<Widget> widget : GetWidgets()) {
		const Point relpos = pos - widget->GetPosition() - widget->GetDrawOffset();
		if (widget->IsContainer()) {
			Widget* w = static_cast<Container*>(widget.Get())->GetWidgetAt(relpos);
			if (w) return w;
		} else if (widget->Contains(relpos))
			return widget.Get();
	}

	return this;
}
開發者ID:AmesianX,項目名稱:pioneer,代碼行數:15,代碼來源:Container.cpp

示例3: SystemGc

void CPositionDisplay::Draw(const TRect& aRect) const
{
   CWindowGc& gc = SystemGc();
   gc.SetClippingRect(aRect);
   gc.SetBrushColor(iBgClr);
   gc.SetBrushStyle(CGraphicsContext::ESolidBrush);

   //gc.Clear(aRect); //paint background color.

   gc.SetPenStyle(CGraphicsContext::ESolidPen);
   gc.SetPenColor(iOutlineClr);
   gc.SetBrushColor(iFldClr);

   if(Contains(iLatControl->Rect(), aRect) || 
      Contains(iLonControl->Rect(), aRect)){
      return;
   }
   TRect bubbles[] = {BoundingRect(iLatControl->Rect(), iLonControl->Rect())};
   const TInt num = sizeof(bubbles)/sizeof(*bubbles);
   for(TInt i = 0; i < num; ++i){
      bubbles[i].Shrink(-2,-2);
      gc.DrawRoundRect(bubbles[i], TSize(8,8));
   }
}
開發者ID:VLjs,項目名稱:Wayfinder-S60-Navigator,代碼行數:24,代碼來源:PositionDisplay.cpp

示例4: Contains

bool PolygonItem::ProcessLeftUp(Point p, dword keyflags)
{
	bool sel = Contains(p);

	p = GetTopRender()->ViewToScene(p);

	if (sel && !IsNull(_click))
	{
		if (abs(_click.x - p.x) < 5 && abs(_click.y - p.y) < 5)
			WhenClick(this);
	}

	_click = Null;
	return IMapItem::ProcessLeftUp(p, keyflags);
}
開發者ID:AbdelghaniDr,項目名稱:mirror,代碼行數:15,代碼來源:PolygonItemEvents.cpp

示例5: MakeHitTest

  int GraphicsBase::MakeHitTest(const glm::vec2& point)
  {
    if (selected_) {
      for (int i = 1; i <= HandleCount(); ++i)
      {
        if (GetHandleRect(i).Contains(point))
          return i;
      }
    }

    if (Contains(point))
      return 0;

    return -1;
  }
開發者ID:yesterdail,項目名稱:deformable-mesh,代碼行數:15,代碼來源:GraphicsBase.cpp

示例6: assert

Window *
WindowList::FindPreviousChildControl(Window *reference)
{
    assert(reference != nullptr);
    assert(Contains(*reference));

    std::list<Window*>::const_reverse_iterator i =
        std::find(list.rbegin(), list.rend(), reference);
#ifndef ANDROID
    /* Android's NDK r5b ships a cxx-stl which does not allow comparing
       two const_reverse_iterator objects for inequality */
    assert(i != list.rend());
#endif

    return FindControl(++i, list.rend());
}
開發者ID:LK8000,項目名稱:LK8000,代碼行數:16,代碼來源:WList.cpp

示例7: FacePlane

bool Polyhedron::Intersects(const LineSegment &lineSegment) const
{
	if (Contains(lineSegment))
		return true;
	for(int i = 0; i < NumFaces(); ++i)
	{
		float t;
		Plane plane = FacePlane(i);
		bool intersects = Plane::IntersectLinePlane(plane.normal, plane.d, lineSegment.a, lineSegment.b - lineSegment.a, t);
		if (intersects && t >= 0.f && t <= 1.f)
			if (FaceContains(i, lineSegment.GetPoint(t)))
				return true;
	}

	return false;
}
開發者ID:360degrees-fi,項目名稱:tundra,代碼行數:16,代碼來源:Polyhedron.cpp

示例8: if

Widget *Container::GetWidgetAt(const Point &pos)
{
	if (!Contains(pos)) return 0;

	for (WidgetIterator i = WidgetsBegin(); i != WidgetsEnd(); ++i) {
		Widget *widget = (*i).Get();
		const Point relpos = pos - widget->GetPosition() - widget->GetDrawOffset();
		if (widget->IsContainer()) {
			Widget* w = static_cast<Container*>(widget)->GetWidgetAt(relpos);
			if (w) return w;
		} else if (widget->Contains(relpos))
			return widget;
	}

	return this;
}
開發者ID:RevOliver,項目名稱:pioneer,代碼行數:16,代碼來源:Container.cpp

示例9: CheckMultiple

//______________________________________________________________________________
void CheckMultiple(const TList& list, const char* title, const char* what)
{
  // check whether the list contains each pad only once
  
  TIter next(&list);
  AliMpPad* pad;
  while ( ( pad = (AliMpPad*)next() ) )
  {
    if ( Contains(list,*pad) != 1 )
    {
      cout << title << " " << what << " pad found more than once : " << endl;
      pad->Print();
    }
  }
      
}
開發者ID:alisw,項目名稱:AliRoot,代碼行數:17,代碼來源:testSt345Pads.C

示例10: Contains

bool AABB::Intersects(const LineSegment &lineSegment) const
{
	vec dir = lineSegment.b - lineSegment.a;
	float len = dir.Length();
	if (len <= 1e-4f) // Degenerate line segment? Fall back to point-in-AABB test.
		return Contains(lineSegment.a);

	float invLen = 1.f / len;
	dir *= invLen;
	float tNear = 0.f, tFar = len;
#ifdef MATH_SIMD
	return IntersectLineAABB_SSE(lineSegment.a, dir, tNear, tFar);
#else
	return IntersectLineAABB_CPP(lineSegment.a, dir, tNear, tFar);
#endif
}
開發者ID:ChunHungLiu,項目名稱:MathGeoLib,代碼行數:16,代碼來源:AABB.cpp

示例11: Contains

/*!	\brief Returns whether this directory or any of its subdirectories
	at any level contain the entry referred to by the supplied path name.
	Only entries that match the node flavor specified by \a nodeFlags are
	considered.
	If the BDirectory is not properly initialized, the method returns \c false.
	A non-absolute path is considered relative to the current directory.

	\note R5's implementation always returns \c true given an absolute path or 
	an unitialized directory. This implementation is not compatible with that
	behavior. Instead it converts the path into a BEntry and passes it to the
	other version of Contains().

	\param path the entry's path name. May be relative to this directory or
		   absolute.
	\param nodeFlags Any of the following:
		   - \c B_FILE_NODE: The entry must be a file.
		   - \c B_DIRECTORY_NODE: The entry must be a directory.
		   - \c B_SYMLINK_NODE: The entry must be a symbolic link.
		   - \c B_ANY_NODE: The entry may be of any kind.
	\return
	- \c true, if the entry exists, its kind does match \nodeFlags and the
	  BDirectory is properly initialized and does contain the entry at any
	  level,
	- \c false, otherwise
*/
bool
BDirectory::Contains(const char *path, int32 nodeFlags) const
{
	// check initialization and parameters
	if (InitCheck() != B_OK)
		return false;
	if (!path)
		return true;	// mimic R5 behavior
	// turn the path into a BEntry and let the other version do the work
	BEntry entry;
	if (BPrivate::Storage::is_absolute_path(path))
		entry.SetTo(path);
	else
		entry.SetTo(this, path);
	return Contains(&entry, nodeFlags);
}
開發者ID:Ithamar,項目名稱:cosmoe,代碼行數:41,代碼來源:Directory.cpp

示例12: FilterMatches

    /**
     * Method FilterMatches
     *
     * Checks if the filter matches the given hotkey
     *
     * @return true on match (or if filter is disabled)
     */
    bool FilterMatches( const EDA_HOTKEY& aHotkey ) const
    {
        if( !m_valid )
            return true;

        // Match in the (translated) filter string
        const auto normedInfo = wxGetTranslation( aHotkey.m_InfoMsg ).Upper();
        if( normedInfo.Contains( m_normalised_filter_str ) )
            return true;

        const wxString keyName = KeyNameFromKeyCode( aHotkey.m_KeyCode );
        if( keyName.Upper().Contains( m_normalised_filter_str ) )
            return true;

        return false;
    }
開發者ID:Lotharyx,項目名稱:kicad-source-mirror,代碼行數:23,代碼來源:widget_hotkey_list.cpp

示例13: UnionPosition

BOOL CPolygon::UnionPosition(SFloat3* psPosition)
{
	CArrayInt	cIndices;
	int			iInsertionIndex;
	int			i;
	int			iIndex;
	
	if (mbConvex)
	{
		if (On(psPosition))
		{
			if (!Contains(psPosition))
			{
				if (HasPositionPtr(psPosition))
				{
					return TRUE;
				}

				cIndices.Init(4);
				FindIndicesOfVisibleHalfSpaces(psPosition, &cIndices);
				if (cIndices.NumElements() == 0)
				{
					//Something went wrong.
					return FALSE;
				}

				iInsertionIndex = cIndices.GetValue(1);  //End index of the first visible line.

				for (i = 2; i < cIndices.NumElements(); i+= 2)
				{
					iIndex = cIndices.GetValue(i);
					mapsPositions.RemoveAt(iIndex);
					if (iIndex < iInsertionIndex)
					{
						iInsertionIndex--;
					}
				}

				mapsPositions.InsertAt(&psPosition, iInsertionIndex);
				cIndices.Kill();
			}
			return TRUE;
		}
		return FALSE;
	}
	return FALSE;
}
開發者ID:chrisjaquet,項目名稱:Codaphela.Library,代碼行數:47,代碼來源:Polygon.cpp

示例14: if

vector<Node*>* Container::AdjacentRemainingNodes(Node* node)
{
	vector<Node*>* adjacentNodes = new vector<Node*>();
	for (unsigned int i = 0; i < edges.size(); ++i) {
		Edge* edge = edges.at(i);
		Node* adjacent = NULL;
		
		if (edge->node1 == node)
			adjacent = edge->node2;
		else if (edge->node2 == node)
			adjacent = edge->node1;
		
		if (adjacent && Contains(nodes, adjacent))
			adjacentNodes->push_back(adjacent);
	}
	return adjacentNodes;
}
開發者ID:Mikulas,項目名稱:Ada,代碼行數:17,代碼來源:Dijkstras.cpp

示例15: FastRandomPointInside

float3 Frustum::UniformRandomPointInside(LCG &rng) const
{
	if (type == OrthographicFrustum)
		return FastRandomPointInside(rng);
	else
	{
		OBB o = MinimalEnclosingOBB();
		for(int numTries = 0; numTries < 1000; ++numTries)
		{
			float3 pt = o.RandomPointInside(rng);
			if (Contains(pt))
				return pt;
		}
		LOGW("Rejection sampling failed in Frustum::UniformRandomPointInside! Producing a non-uniformly distributed point inside the frustum!");
		return FastRandomPointInside(rng);
	}
}
開發者ID:chengzg,項目名稱:MathGeoLib,代碼行數:17,代碼來源:Frustum.cpp


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