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

C++ tvector类代码示例

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

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



在下文中一共展示了tvector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mySize

tvector<itemType>::tvector(const tvector<itemType> & vec)
// postcondition: vector is a copy of vec
    : mySize(vec.size()),
      myCapacity(vec.capacity()),
      myList(new itemType[myCapacity])
{
    int k;
        // copy elements
    for(k = 0; k < mySize; k++){
        myList[k] = vec.myList[k];
    }
}
开发者ID:ljw3351639,项目名称:college-work,代码行数:12,代码来源:tvector.cpp


示例2: assert

tvector<nr_type_t> operator * (tvector<nr_type_t> a, tmatrix<nr_type_t> b) {
  assert (a.size () == b.getRows ());
  int r, c, n = b.getRows ();
  nr_type_t z;
  tvector<nr_type_t> res (n);

  for (c = 0; c < n; c++) {
    for (r = 0, z = 0; r < n; r++) z += a.get (r) * b.get (r, c);
    res.set (c, z);
  }
  return res;
}
开发者ID:FoxMarts,项目名称:qucs,代码行数:12,代码来源:tmatrix.cpp


示例3: KickPlayer

void KickPlayer(class CCommand* pCommand, tvector<tstring>& asTokens, const tstring& sCommand)
{
	if (!asTokens.size())
		return;

	GameNetwork()->DisconnectClient(stoi(asTokens[0]));
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:7,代码来源:gameserver.cpp


示例4: FindEar

size_t FindEar(const tvector<vec3>& avecPoints)
{
	size_t iPoints = avecPoints.size();

	// A triangle is always an ear.
	if (iPoints <= 3)
		return 0;

	size_t i;

	vec3 vecFaceNormal;

	// Calculate the face normal.
	for (i = 0; i < iPoints; i++)
	{
		size_t iNext = (i+1)%iPoints;

		vec3 vecPoint = avecPoints[i];
		vec3 vecNextPoint = avecPoints[iNext];

		vecFaceNormal.x += (vecPoint.y - vecNextPoint.y) * (vecPoint.z + vecNextPoint.z);
		vecFaceNormal.y += (vecPoint.z - vecNextPoint.z) * (vecPoint.x + vecNextPoint.x);
		vecFaceNormal.z += (vecPoint.x - vecNextPoint.x) * (vecPoint.y + vecNextPoint.y);
	}

	vecFaceNormal.Normalize();

	for (i = 0; i < iPoints; i++)
	{
		size_t iLast = i==0?iPoints-1:i-1;
		size_t iNext = i==iPoints-1?0:i+1;

		vec3 vecLast = avecPoints[iLast];
		vec3 vecThis = avecPoints[i];
		vec3 vecNext = avecPoints[iNext];

		// Concave ones can not be ears.
		if ((vecLast-vecThis).Cross(vecLast-vecNext).Dot(vecFaceNormal) < 0)
			continue;

		bool bFoundPoint = false;
		for (size_t j = 0; j < iPoints; j++)
		{
			if (j == i || j == iLast || j == iNext)
				continue;

			if (PointInTriangle(avecPoints[j], vecLast, vecThis, vecNext))
			{
				bFoundPoint = true;
				break;
			}
		}

		if (!bFoundPoint)
			return i;
	}

	return 0;
}
开发者ID:ezhangle,项目名称:DrawSomething,代码行数:59,代码来源:geometry.cpp


示例5: glfwGetJoystickPos

void CApplication::ProcessJoystickInput()
{
	if (g_aJoysticks.size() != MAX_JOYSTICKS)
		return;

	for (size_t i = 0; i < MAX_JOYSTICKS; i++)
	{
		CJoystick& oJoystick = g_aJoysticks[i];

		if (!oJoystick.m_bPresent)
			continue;

		static tvector<float> aflAxis;
		aflAxis.resize(oJoystick.m_aflAxis.size());
		glfwGetJoystickPos(i, &aflAxis[0], oJoystick.m_aflAxis.size());

		for (size_t j = 0; j < oJoystick.m_aflAxis.size(); j++)
		{
			if (aflAxis[j] != oJoystick.m_aflAxis[j])
				JoystickAxis(i, j, aflAxis[j], aflAxis[j]-oJoystick.m_aflAxis[j]);
		}

		oJoystick.m_aflAxis = aflAxis;

		static tvector<unsigned char> aiButtons;
		aiButtons.resize(oJoystick.m_iButtons);
		glfwGetJoystickButtons(i, &aiButtons[0], oJoystick.m_iButtons);

		for (size_t j = 0; j < oJoystick.m_iButtons; j++)
		{
			unsigned long long iButtonMask = (1<<j);
			if (aiButtons[j] == GLFW_PRESS && !(oJoystick.m_aiButtonStates&iButtonMask))
				JoystickButtonPress(i, MapJoystickKey(j));
			else if (aiButtons[j] == GLFW_RELEASE && (oJoystick.m_aiButtonStates&iButtonMask))
				JoystickButtonRelease(i, MapJoystickKey(j));

			if (aiButtons[j] == GLFW_PRESS)
				oJoystick.m_aiButtonStates |= iButtonMask;
			else
				oJoystick.m_aiButtonStates &= ~iButtonMask;
		}
	}
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:43,代码来源:application.cpp


示例6: SetCVar

void SetCVar(CCommand* pCommand, tvector<tstring>& asTokens, const tstring& sCommand)
{
	CVar* pCVar = dynamic_cast<CVar*>(pCommand);
	TAssert(pCVar);
	if (!pCVar)
		return;

	if (asTokens.size() > 1)
		pCVar->SetValue(asTokens[1]);

	TMsg(sprintf(tstring("%s = %s\n"), pCVar->GetName().c_str(), pCVar->GetValue().c_str()));
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:12,代码来源:cvar.cpp


示例7: DestroyAllEntities

void CGameServer::DestroyAllEntities(const tvector<tstring>& asSpare, bool bRemakeGame)
{
	if (!GameNetwork()->IsHost() && !IsLoading())
		return;

	if (m_pWorkListener)
		m_pWorkListener->SetAction("Locating dead nodes", GameServer()->GetMaxEntities());

	for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++)
	{
		CBaseEntity* pEntity = CBaseEntity::GetEntity(i);
		if (!pEntity)
			continue;

		bool bSpare = false;
		for (size_t j = 0; j < asSpare.size(); j++)
		{
			if (asSpare[j] == pEntity->GetClassName())
			{
				bSpare = true;
				break;
			}
		}

		if (bSpare)
			continue;

		pEntity->Delete();

		if (m_pWorkListener)
			m_pWorkListener->WorkProgress(i);
	}

	if (m_pWorkListener)
		m_pWorkListener->SetAction("Clearing buffers", GameServer()->m_ahDeletedEntities.size());

	for (size_t i = 0; i < GameServer()->m_ahDeletedEntities.size(); i++)
	{
		delete GameServer()->m_ahDeletedEntities[i];

		if (m_pWorkListener)
			m_pWorkListener->WorkProgress(i);
	}

	GameServer()->m_ahDeletedEntities.clear();

	if (CBaseEntity::GetNumEntities() == 0)
		CBaseEntity::s_iNextEntityListIndex = 0;

	if (bRemakeGame && GameNetwork()->IsHost())
		m_hGame = CreateGame();
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:52,代码来源:gameserver.cpp


示例8: DistanceToPolygon

float DistanceToPolygon(const vec3& p, tvector<vec3>& v, vec3 n)
{
	float flPlaneDistance = DistanceToPlane(p, v[0], n);

	size_t i;

	bool bFoundPoint = false;

	for (i = 0; i < v.size()-2; i++)
	{
		if (PointInTriangle(p, v[0], v[i+1], v[i+2]))
		{
			bFoundPoint = true;
			break;
		}
	}

	if (bFoundPoint)
		return flPlaneDistance;

	float flClosestPoint = -1;
	for (i = 0; i < v.size(); i++)
	{
		float flPointDistance = (v[i] - p).Length();
		if (flClosestPoint == -1 || (flPointDistance < flClosestPoint))
			flClosestPoint = flPointDistance;

		float flLineDistance;
		if (i == v.size() - 1)
			flLineDistance = DistanceToLineSegment(p, v[i], v[0]);
		else
			flLineDistance = DistanceToLineSegment(p, v[i], v[i+1]);

		if (flClosestPoint == -1 || (flLineDistance < flClosestPoint))
			flClosestPoint = flLineDistance;
	}

	return flClosestPoint;
}
开发者ID:ezhangle,项目名称:DrawSomething,代码行数:39,代码来源:geometry.cpp


示例9:

const tvector<itemType> &
tvector<itemType>::operator = (const tvector<itemType> & rhs)
// postcondition: normal assignment via copying has been performed;
//                if vector and rhs were different sizes, vector
//                has been resized to  match the size of rhs
{
    if (this != &rhs)                           // don't assign to self!
    {
        delete [] myList;                       // get rid of old storage
        myCapacity = rhs.capacity();
        mySize =     rhs.size();
        myList = new itemType [myCapacity];         // allocate new storage

            // copy rhs
        int k;
        for(k=0; k < mySize; k++)
        {
            myList[k] = rhs.myList[k];
        }
    }
    return *this;                               // permit a = b = c = d
}
开发者ID:ljw3351639,项目名称:college-work,代码行数:22,代码来源:tvector.cpp


示例10: FireInput

void FireInput(class CCommand* pCommand, tvector<tstring>& asTokens, const tstring& sCommand)
{
	if (!CVar::GetCVarBool("cheats"))
		return;

	if (asTokens.size() < 3)
	{
		TMsg("Format: ent_input entityname input [optional args]\n");
		return;
	}

	tvector<CBaseEntity*> apEntities;
	CBaseEntity::FindEntitiesByName(asTokens[1], apEntities);

	if (!apEntities.size())
	{
		if (CVar::GetCVarBool("debug_entity_outputs"))
			TMsg("Console -> none\n");
		else
			TError("No entities found that match name \"" + asTokens[1] + "\".\n");

		return;
	}

	tstring sArgs;
	for (size_t i = 3; i < asTokens.size(); i++)
		sArgs += asTokens[i] + " ";

	for (size_t i = 0; i < apEntities.size(); i++)
	{
		CBaseEntity* pTargetEntity = apEntities[i];

		if (CVar::GetCVarBool("debug_entity_outputs"))
			TMsg("Console -> " + tstring(pTargetEntity->GetClassName()) + "(\"" + pTargetEntity->GetName() + "\")." + asTokens[2] + "(\"" + sArgs + "\")\n");

		pTargetEntity->CallInput(asTokens[2], sArgs);
	}
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:38,代码来源:gameserver.cpp


示例11: ConvexHullIntersectsAABB

bool ConvexHullIntersectsAABB(const AABB& box, const tvector<vec3>& avecPoints, const tvector<size_t>& aiTriangles)
{
	TAssert(aiTriangles.size() % 3 == 0);

	vec3 vecCenter = box.Center();
	vec3 n;

	for (size_t i = 0; i < aiTriangles.size(); i += 3)
	{
		const vec3& v1 = avecPoints[aiTriangles[i]];
		const vec3& v2 = avecPoints[aiTriangles[i+1]];
		const vec3& v3 = avecPoints[aiTriangles[i+2]];

		n = (v2-v1).Cross(v3-v1).Normalized();

		if (n.Dot(vecCenter-v1) < 0)
			continue;

		if (!TriangleIntersectsAABB(box, v1, v2, v3))
			return false;
	}

	return true;
}
开发者ID:ezhangle,项目名称:DrawSomething,代码行数:24,代码来源:geometry.cpp


示例12: norm

nr_double_t norm (tvector<nr_type_t> a) {
#if 0
  nr_double_t k = 0;
  for (int i = 0; i < a.getSize (); i++) k += norm (a.get (i));
  return n;
#else
  nr_double_t scale = 0, n = 1, x, ax;
  for (int i = 0; i < a.getSize (); i++) {
    if ((x = real (a (i))) != 0) {
      ax = fabs (x);
      if (scale < ax) {
	x = scale / ax;
	n = 1 + n * x * x;
	scale = ax;
      }
      else {
	x = ax / scale;
	n += x * x;
      }
    }
    if ((x = imag (a (i))) != 0) {
      ax = fabs (x);
      if (scale < ax) {
	x = scale / ax;
	n = 1 + n * x * x;
	scale = ax;
      }
      else {
	x = ax / scale;
	n += x * x;
      }
    }
  }
  return scale * scale * n;
#endif
}
开发者ID:Freecore,项目名称:qucs,代码行数:36,代码来源:tvector.cpp


示例13: eval_grad

                        // implementation: approximate gradient (if no analytic gradient provided)
                        void eval_grad(const tvector& x, tvector& g) const
                        {
                                // accuracy epsilon as defined in:
                                //      see "Numerical optimization", Nocedal & Wright, 2nd edition, p.197
                                const tscalar dx = std::cbrt(tscalar(10) * std::numeric_limits<tscalar>::epsilon());

                                const tsize n = size();

                                tvector xp = x, xn = x;

                                g.resize(n);
                                for (tsize i = 0; i < n; i ++)
                                {
                                        if (i > 0)
                                        {
                                                xp(i - 1) -= dx;
                                                xn(i - 1) += dx;
                                        }
                                        xp(i) += dx;
                                        xn(i) -= dx;

                                        g(i) = (m_op_fval(xp) - m_op_fval(xn)) / (xp(i) - xn(i));
                                }
                        }
开发者ID:0x0all,项目名称:nanocv,代码行数:25,代码来源:problem.hpp


示例14: scalar

nr_type_t scalar (tvector<nr_type_t> a, tvector<nr_type_t> b) {
  assert (a.getSize () == b.getSize ());
  nr_type_t n = 0;
  for (int i = 0; i < a.getSize (); i++) n += a.get (i) * b.get (i);
  return n;
}
开发者ID:Freecore,项目名称:qucs,代码行数:6,代码来源:tvector.cpp


示例15: assert

void tmatrix<nr_type_t>::setCol (int c, tvector<nr_type_t> v) {
  assert (c >= 0 && c < cols && v.getSize () == rows);
  nr_type_t * dst = &data[c];
  nr_type_t * src = v.getData ();
  for (int r = 0; r < rows; r++, src++, dst += cols) *dst = *src;
}
开发者ID:jonnyro,项目名称:arduino_motorcycle_gauges,代码行数:6,代码来源:tmatrix.cpp


示例16: LoadMesh

void LoadMesh(CConversionScene* pScene, size_t iMesh)
{
	TAssert(iMesh < pScene->GetNumMeshes());
	if (iMesh >= pScene->GetNumMeshes())
		return;

	// Reserve space for n+1, the last one represents the default material.
	g_aaflData.resize(pScene->GetNumMaterials()+1);

	tvector<Vector> avecPoints;
	tvector<size_t> aiPoints;

	CConversionMesh* pMesh = pScene->GetMesh(iMesh);

	for (size_t j = 0; j < pMesh->GetNumFaces(); j++)
	{
		CConversionFace* pFace = pMesh->GetFace(j);

		size_t iMaterial = pFace->m;
		if (iMaterial == ~0)
			iMaterial = pScene->GetNumMaterials();

		CConversionVertex* pVertex0 = pFace->GetVertex(0);
		CConversionVertex* pVertex1 = pFace->GetVertex(1);

		CConversionVertex* pLastVertex = pFace->GetVertex(pFace->GetNumVertices()-1);

		avecPoints.clear();
		aiPoints.clear();

		for (size_t t = 0; t < pFace->GetNumVertices(); t++)
		{
			avecPoints.push_back(pMesh->GetVertex(pFace->GetVertex(t)->v));
			aiPoints.push_back(t);
		}

		CConversionVertex* pVertex2;

		while (avecPoints.size() > 3)
		{
			size_t iEar = FindEar(avecPoints);
			size_t iLast = iEar==0?avecPoints.size()-1:iEar-1;
			size_t iNext = iEar==avecPoints.size()-1?0:iEar+1;

			pVertex0 = pFace->GetVertex(aiPoints[iLast]);
			pVertex1 = pFace->GetVertex(aiPoints[iEar]);
			pVertex2 = pFace->GetVertex(aiPoints[iNext]);

			AddVertex(iMaterial, pMesh->GetVertex(pVertex0->v), pMesh->GetUV(pVertex0->vu));
			AddVertex(iMaterial, pMesh->GetVertex(pVertex1->v), pMesh->GetUV(pVertex1->vu));
			AddVertex(iMaterial, pMesh->GetVertex(pVertex2->v), pMesh->GetUV(pVertex2->vu));

			avecPoints.erase(avecPoints.begin()+iEar);
			aiPoints.erase(aiPoints.begin()+iEar);
		}

		TAssert(aiPoints.size() == 3);
		if (aiPoints.size() != 3)
			continue;

		pVertex0 = pFace->GetVertex(aiPoints[0]);
		pVertex1 = pFace->GetVertex(aiPoints[1]);
		pVertex2 = pFace->GetVertex(aiPoints[2]);

		AddVertex(iMaterial, pMesh->GetVertex(pVertex0->v), pMesh->GetUV(pVertex0->vu));
		AddVertex(iMaterial, pMesh->GetVertex(pVertex1->v), pMesh->GetUV(pVertex1->vu));
		AddVertex(iMaterial, pMesh->GetVertex(pVertex2->v), pMesh->GetUV(pVertex2->vu));
	}
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:69,代码来源:loadsource.cpp


示例17: conj

tvector<nr_type_t> conj (tvector<nr_type_t> a) {
  int n = a.getSize ();
  tvector<nr_type_t> res (n);
  for (int i = 0; i < n; i++) res.set (i, conj (a.get (i)));
  return res;
}
开发者ID:Freecore,项目名称:qucs,代码行数:6,代码来源:tvector.cpp


示例18: res

tvector<nr_type_t> operator + (nr_type_t s, tvector<nr_type_t> a) {
  int n = a.getSize ();
  tvector<nr_type_t> res (n);
  for (int i = 0; i < n; i++) res.set (i, s + a.get (i));
  return res;
}
开发者ID:Freecore,项目名称:qucs,代码行数:6,代码来源:tvector.cpp


示例19: assert

bool operator > (tvector<nr_type_t> a, tvector<nr_type_t> b) {
  assert (a.getSize () == b.getSize ());
  int n = a.getSize ();
  for (int i = 0; i < n; i++) if (a.get (i) <= b.get (i)) return false;
  return true;
}
开发者ID:Freecore,项目名称:qucs,代码行数:6,代码来源:tvector.cpp


示例20: sum

nr_type_t sum (tvector<nr_type_t> a) {
  nr_type_t res = 0;
  for (int i = 0; i < a.getSize (); i++) res += a.get (i);
  return res;
}
开发者ID:Freecore,项目名称:qucs,代码行数:5,代码来源:tvector.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ twindow类代码示例发布时间:2022-05-31
下一篇:
C++ tuple类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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