当前位置: 首页>>代码示例>>C++>>正文


C++ List::Add方法代码示例

本文整理汇总了C++中List::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ List::Add方法的具体用法?C++ List::Add怎么用?C++ List::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


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

示例1: TestSerialization

void TestSerialization() {
    Stream stream(L"test.dat", true);
    List<int> l;
    l.Add(1);
    l.Add(2);
    l.Add(3);
    l.Serialize(stream);
    l.Clear();
    stream.Close();

    stream.Open(L"test.dat");
    l.Deserialize(stream);

    List<Point> b;
    b.Add(Point(1, 2, 3));
    b.Add(Point(4, 5, 6));
    b.Add(Point(7, 8, 9));
    stream.Close();
    stream.Open(L"test.dat", true);
    b.Serialize(stream);
    
    stream.Close();

    stream.Open(L"test.dat");
    b.Deserialize(stream);
}
开发者ID:UIKit0,项目名称:ObjectExtrusion3D,代码行数:26,代码来源:Tests.hpp

示例2: Guard

/** Used to tokenize with some characters used to start and stop the tokenization procedure temporarily.
	Sample use-case would be to tokenize the string "Aim(7,3), Guard(2,3)" and returning "Aim(7,3)" and "Guard(2,3)",
	using the tokenizer ',' and ignoreparts "()". 
	Ignore parts should be in pairs, one starting the ignore part, the other stopping it.
*/
List<String> TokenizeIgnore(String string, String tokenizers, String ignoreParts)
{
	List<String> tokens;
	int inIgnorePart = 0;
	const char * cString = string.c_str();
	String str;
	for (int i = 0; i < string.Length(); ++i)
	{
		char c = cString[i];
		for (int i = 0; i < ignoreParts.Length(); i += 2)
		{
			if (c == ignoreParts.c_str()[i])
				++inIgnorePart;
			if (c == ignoreParts.c_str()[i+1])
				--inIgnorePart;
		}

		if (tokenizers.Contains(c) && inIgnorePart == 0)
		{
			tokens.Add(str);
			str = String();
		}
		else 
		{
			str += c;
		}
	}
	// Add final one.
	tokens.Add(str);
	return tokens;
}
开发者ID:erenik,项目名称:engine,代码行数:36,代码来源:StringUtil.cpp

示例3: TestStoryboard

void TestStoryboard() {
    List<Point> points;
    points.Add(Point(0, 0, 0));
    points.Add(Point(1, 1, 1));
    points.Add(Point(2, 2, 2));
    points.Add(Point(3, 3, 3));

    Shape shape(points);
    IAction* a = new TranslateAction(3, 3 , 3);
    IAction* b = new TranslateAction(2, 2 , 2);
    IAction* c = new TranslateAction(5, 5 , 5);
    a->SetSteps(3);
    b->SetSteps(3);
    c->SetSteps(4);
    b->SetWithPrevious(true);

    Storyboard sb;
    sb.Actions().Add(a);
    sb.Actions().Add(b);
    sb.Actions().Add(c);
    sb.SetShapeObject(shape);

    assert(sb.TotalSteps() == 10);
    assert(sb.CurrentAction() == NULL);

    sb.Play();
    for(size_t i = 0; i < sb.TotalSteps(); i++) {
        sb.NextStep();
    }
}
开发者ID:UIKit0,项目名称:ObjectExtrusion3D,代码行数:30,代码来源:Tests.hpp

示例4: FixConstraintsForPointBeingDeleted

void GraphicsWindow::FixConstraintsForPointBeingDeleted(hEntity hpt) {
    List<hEntity> ld;
    ZERO(&ld);

    Constraint *c;
    SK.constraint.ClearTags();
    for(c = SK.constraint.First(); c; c = SK.constraint.NextAfter(c)) {
        if(c->type != Constraint::POINTS_COINCIDENT) continue;
        if(c->group.v != SS.GW.activeGroup.v) continue;

        if(c->ptA.v == hpt.v) {
            ld.Add(&(c->ptB));
            c->tag = 1;
        }
        if(c->ptB.v == hpt.v) {
            ld.Add(&(c->ptA));
            c->tag = 1;
        }
    }
    // These would get removed anyways when we regenerated, but do it now;
    // that way subsequent calls of this function (if multiple coincident
    // points are getting deleted) will work correctly.
    SK.constraint.RemoveTagged();

    // If more than one point was constrained coincident with hpt, then
    // those two points were implicitly coincident with each other. By
    // deleting hpt (and all constraints that mention it), we will delete
    // that relationship. So put it back here now.
    int i;
    for(i = 1; i < ld.n; i++) {
        Constraint::ConstrainCoincident(ld.elem[i-1], ld.elem[i]);
    }
    ld.Clear();
}
开发者ID:BBBSnowball,项目名称:python-solvespace,代码行数:34,代码来源:modify.cpp

示例5: EvalFunctionReferenceClosure

		void SymbolTable::EvalFunctionReferenceClosure()
		{
			for (auto & func : Functions)
			{
				List<String> funcList;
				EnumerableHashSet<String> funcSet;
				for (auto & ref : func.Value->ReferencedFunctions)
				{
					funcList.Add(ref);
					funcSet.Add(ref);
				}
				for (int i = 0; i < funcList.Count(); i++)
				{
					RefPtr<FunctionSymbol> funcSym;
					if (Functions.TryGetValue(funcList[i], funcSym))
					{
						for (auto rfunc : funcSym->ReferencedFunctions)
						{
							if (funcSet.Add(rfunc))
								funcList.Add(rfunc);
						}
					}
				}
				func.Value->ReferencedFunctions = _Move(funcSet);
			}
		}
开发者ID:daliniu,项目名称:Spire,代码行数:26,代码来源:SymbolTable.cpp

示例6: UnFocus

	void UIBase::UnFocus() {
		List<UIBase*> childs;
		childs.Add(this);

		bool found = false;

		UIBase* c = nullptr;
		while (childs.Count > 0) {
			c = childs[childs.Count - 1];
			childs.RemoveAt(childs.Count - 1);

			if (this->UIMan != nullptr && c == this->UIMan->FocusPanel) {
				found = true;
				break;
			} else {
				for (unsigned int i = 0; i < c->Children.size(); i++) {
					childs.Add(c->Children[i]);
				}
			}
		}

		if (!found) return;

		if (this->UIMan != nullptr) this->UIMan->FocusPanel = nullptr;
		c->OnFocus(false);
	}
开发者ID:edunad,项目名称:TomatoLib,代码行数:26,代码来源:UIBase.cpp

示例7: List

List* operator+ (List& ls1, List& ls2)
{

	List *newList = new List();
	List *temp = ls1.head;

	while (temp)
	{
		newList->Add(temp->getNumber());
		temp = temp->next;
	}

	temp = ls2.head;

	while (temp)
	{


		newList->Add(temp->getNumber());
		temp = temp->next;

	}

	return newList;

}
开发者ID:ArtemPaivin,项目名称:laboratornie,代码行数:26,代码来源:List.cpp

示例8: Deserialize

    virtual void Deserialize(Stream &stream) {
        ClearActions();
        size_t count;
        stream.Read(count);

        for(size_t i = 0; i < count; i++) {
            int temp;
            stream.Read(temp);
            ActionType type = (ActionType)temp;

            switch(type) {
                case ACTION_TRANSLATE: {
                    TranslateAction *action = new TranslateAction();
                    stream.Read(*action);
                    actions_.Add(action);
                    break;
                }
                case ACTION_SCALE: {
                    ScaleAction *action = new ScaleAction();
                    stream.Read(*action);
                    actions_.Add(action);
                    break;
                }
                case ACTION_ROTATE: {
                    RotateAction *action = new RotateAction();
                    stream.Read(*action);
                    actions_.Add(action);
                    break;
                }
            }
        }
    }
开发者ID:UIKit0,项目名称:ObjectExtrusion3D,代码行数:32,代码来源:Storyboard.hpp

示例9: main

int main()
{
	List myList = List();
	List myList2 = List();
	myList.Add(1);
	myList.Add(2);
	myList.Add(3);
	myList.Add(4);
	myList.Add(5);
	myList.Add(6);

	myList2.Add(1);
	myList2.Add(2);
	myList2.Add(3);
	myList2.Add(4);
	myList2.Add(5);
	myList2.Add(6);

	myList.tail->next = myList.head->next;

	checkForDuplicates(myList2.head);
	

	system("pause");
	return 0;
}
开发者ID:adadevoh,项目名称:Sample-coding-Problems,代码行数:26,代码来源:CheckCycle.cpp

示例10: UpdateMesh

void FntLabel::UpdateMesh()
{
	if (mString.IsEmpty())
	{
		if (mFont->HasSinglePage() && mFont->IsFixed())
		{
			SetMesh(nullptr);
			SetMaterial(nullptr);
		}

		if (!mManagedNodes.IsEmpty())
		{
			DeleteAllChilds(NodeRemoveFlags::OnlyManaged);
		}
		SetSize(Size2F::Zero);
		mInternalMeshes.Clear();
		return;
	}
	else if (mRenderingObject.Mesh() ==nullptr)
	{
		CreateMesh();
	}


	Size2F outSize;

	if (mIsMultipleLine)
	{
		TextLayouter::LayoutMultipleLineText(mInternalMeshes, mInternalPages, outSize, *mFont, mString, mAlignment, mRestrictSize, this, mIsStatic);
	}
	else
	{
		TextLayouter::LayoutSingleLineText(mInternalMeshes, mInternalPages, outSize, *mFont, mString, mAlignment, mRestrictSize, this, mIsStatic);
	}

	SetSize(outSize);

	//check if there are some mesh has no char after layout,this is rarely hit
	size_t meshCount = mInternalMeshes.Count();
	if (meshCount>1)
	{
		List<size_t> unusedIndices;
		List<INode*> unusedSprites;
		FOR_EACH_SIZE(i, meshCount)
		{
			BaseFontMesh* mesh = mInternalMeshes[i];
			if (!mesh->HasChars())
			{
				unusedIndices.Add(i);
				unusedSprites.Add(mManagedNodes[i]);
			}
		}
开发者ID:xuxiaowei007,项目名称:Medusa,代码行数:52,代码来源:FntLabel.cpp

示例11: get_processes

int get_processes ( List &processes , List &uptimes )
{
  PROCESSENTRY32 process;
  HANDLE handle;
  HANDLE phandle;
  int mypid;
  int ret = TRUE;

/* Getting my process ID */
  mypid = GetCurrentProcessId ();

/* Cleaning list */
  processes.Clear ();
  uptimes.Clear ();

/* Getting process list */
  handle = CreateToolhelp32Snapshot ( TH32CS_SNAPALL , 0 );

/* Initializing structure */
  process.dwSize = sizeof ( PROCESSENTRY32 );

/* Getting first process */
  Process32First ( handle , &process );

/* Adding the PID */
  processes.Add ( ( void * ) process.th32ProcessID );

/* Getting the uptime of this process */
  uptimes.Add ( ( void * ) get_process_uptime ( process.th32ProcessID ) );

/* Getting the rest of the processes */
  while ( Process32Next ( handle , &process ) == TRUE )
  {
  /* If it's not me */
    if ( mypid != process.th32ProcessID )
    {
    /* Adding the PID */
      processes.Add ( ( void * ) process.th32ProcessID );

    /* Getting the uptime of this process */
      uptimes.Add ( ( void * ) get_process_uptime ( process.th32ProcessID ) );
    }
  }

/* Ordering process list */
  processes.SortCouple ( uptimes );

/* Closing handle */
  CloseHandle ( handle );

  return ( ret );
}
开发者ID:CoreSecurity,项目名称:Embarcadero-Workaround,代码行数:52,代码来源:Embarcadero-Workaround.cpp

示例12: CreateIndices

void Node::CreateIndices()
{
	for (int n=0;n < m_list.GetNum();n++)
	{
		unsigned short i;
		i = this->AddVector(m_list[n].a);
		m_indices.Add(i);
		i = this->AddVector(m_list[n].b);
		m_indices.Add(i);
		i = this->AddVector(m_list[n].c);
		m_indices.Add(i);
	}
	m_list.Clean();
}
开发者ID:gejza,项目名称:Hoe3D,代码行数:14,代码来源:terrain.cpp

示例13: TestList

void TestList() {
    List<int> a;
    a.Add(3);
    a.Add(5);
    assert(a.Count() == 2);
    assert(a.Contains(3));
    assert(a.Contains(5));
    assert(a[0] == 3);

    List<int> b(a);
    b.Add(a);
    assert(b.Count() == 4);
    a.Remove(3);
    assert(a.Count() == 1);
    assert(a.Contains(3) == false);
    assert(a[0] = 5);
    
    a.Insert(4, 0);
    a.Insert(6, 1);
    a.Insert(7, a.Count() - 1);
    assert(a[0] == 4);
    assert(a[1] == 6);
    assert(a[2] == 7);

    a.Remove(6);
    assert(a[2] == 5);
}
开发者ID:UIKit0,项目名称:ObjectExtrusion3D,代码行数:27,代码来源:Tests.hpp

示例14:

List<SRPWindows*> *Gui::GetMouseEnabledWindows()
{
	// create an empty list
	List<SRPWindows*> *pList = new List<SRPWindows*>;

	// get the iterator for all the windows
	Iterator<SRPWindows*> cIterator = m_pWindows->GetIterator();
	// loop trough the windows
	while (cIterator.HasNext())
	{
		SRPWindows *pSRPWindows = cIterator.Next();
		if (pSRPWindows->GetData()->bIsVisable && pSRPWindows->GetData()->bMouseEnabled)
		{
			// if the window is visible and the mouse for the window is enabled then add the window to the list
			pList->Add(pSRPWindows);
		}
	}

	if (pList->GetNumOfElements() > 0)
	{
		// list has items so return the list
		return pList;
	}
	else
	{
		// return nothing because the list is empty
		return nullptr;
	}
}
开发者ID:PixelLightCommunity,项目名称:Plugins,代码行数:29,代码来源:Gui.cpp

示例15: Dispose

		void Application::Dispose()
		{
			{
				List<BaseForm *> forms;
				for (auto & c : *components)
				{
					if (c.Value)
					{
						BaseForm * ctrl = dynamic_cast<BaseForm*>(c.Value);
						if (ctrl)
						{
							forms.Add(ctrl);		
						}
						c.Value = 0;
					}
				}
				for (int i=0; i<forms.Count(); i++)
					delete forms[i];
				delete components;
				delete cmdLine;
				delete objMap;
				delete onMainLoop;
			}
			GdiplusShutdown(gdiToken);

			_CrtDumpMemoryLeaks();
		}
开发者ID:lixf,项目名称:15869-p1,代码行数:27,代码来源:WinApp.cpp


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