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


C++ TArray::Insert方法代码示例

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


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

示例1: CreateCookerFileOrderString

FString FChunkManifestGenerator::CreateCookerFileOrderString(const TMap<FName, FAssetData*>& InAssetData, const TArray<FName>& InMaps)
{
	FString FileOrderString;
	TArray<FAssetData*> TopLevelNodes;

	for (auto Asset : InAssetData)
	{
		auto PackageName = Asset.Value->PackageName;
		TArray<FName> Referencers;
		AssetRegistry.GetReferencers(PackageName, Referencers);

		bool bIsTopLevel = true;
		bool bIsMap = InMaps.Contains(PackageName);

		if (!bIsMap && Referencers.Num() > 0)
		{
			for (auto ReferencerName : Referencers)
			{
				if (InAssetData.Contains(ReferencerName))
				{
					bIsTopLevel = false;
					break;
				}
			}
		}

		if (bIsTopLevel)
		{
			if (bIsMap)
			{
				TopLevelNodes.Insert(Asset.Value, 0);
			}
			else
			{
				TopLevelNodes.Insert(Asset.Value, TopLevelNodes.Num());
			}
		}
	}

	TArray<FName> FileOrder;
	TArray<FName> EncounteredNames;
	for (auto Asset : TopLevelNodes)
	{
		AddAssetToFileOrderRecursive(Asset, FileOrder, EncounteredNames, InAssetData, InMaps);
	}

	int32 CurrentIndex = 0;
	for (auto PackageName : FileOrder)
	{
		auto Asset = InAssetData[PackageName];
		bool bIsMap = InMaps.Contains(Asset->PackageName);
		auto Filename = FPackageName::LongPackageNameToFilename(Asset->PackageName.ToString(), bIsMap ? FPackageName::GetMapPackageExtension() : FPackageName::GetAssetPackageExtension());

		ConvertFilenameToPakFormat(Filename);
		auto Line = FString::Printf(TEXT("\"%s\" %i\n"), *Filename, CurrentIndex++);
		FileOrderString.Append(Line);
	}

	return FileOrderString;
}
开发者ID:VZout,项目名称:Team6UnrealEngine,代码行数:60,代码来源:ChunkManifestGenerator.cpp

示例2: ArrangeWindowToFront

void FSlateWindowHelper::ArrangeWindowToFront( TArray< TSharedRef<SWindow> >& Windows, const TSharedRef<SWindow>& WindowToBringToFront )
{
	Windows.Remove(WindowToBringToFront);

	if ((Windows.Num() == 0) || WindowToBringToFront->IsTopmostWindow())
	{
		Windows.Add(WindowToBringToFront);
	}
	else
	{
		bool PerformedInsert = false;

		for (int WindowIndex = Windows.Num() - 1; WindowIndex >= 0; --WindowIndex)
		{
			if (!Windows[WindowIndex]->IsTopmostWindow())
			{
				Windows.Insert(WindowToBringToFront, WindowIndex + 1);
				PerformedInsert = true;

				break;
			}
		}

		if (!PerformedInsert)
		{
			Windows.Insert(WindowToBringToFront, 0);
		}
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:29,代码来源:SlateWindowHelper.cpp

示例3: InsertRecursive

		/**
		 * Recursively look for `TargetItem` in `InsertInto` and any of the descendants.
		 * Insert `ItemToInsert` relative to the target.
		 * Relative positioning dictated by `RelativeLocation`.
		 *
		 * @return true when successful.
		 */
		static bool InsertRecursive(TArray< TSharedPtr< FTestData > >& InsertInto, const TSharedRef<FTestData>& ItemToInsert, const TSharedRef<FTestData>& TargetItem, EItemDropZone RelativeLocation)
		{
			const int32 TargetIndex = InsertInto.Find(TargetItem);
			if (TargetIndex != INDEX_NONE)
			{
				if (RelativeLocation == EItemDropZone::AboveItem)
				{
					InsertInto.Insert(ItemToInsert, TargetIndex);
				}
				else if (RelativeLocation == EItemDropZone::BelowItem)
				{
					InsertInto.Insert(ItemToInsert, TargetIndex + 1);
				}
				else
				{
					ensure(RelativeLocation == EItemDropZone::OntoItem);
					InsertInto[TargetIndex]->Children.Insert(ItemToInsert, 0);
				}				
				return true;
			}

			// Did not successfully remove an item. Try all the children.
			for (int32 ItemIndex = 0; ItemIndex < InsertInto.Num(); ++ItemIndex)
			{
				if (InsertRecursive(InsertInto[ItemIndex]->Children, ItemToInsert, TargetItem, RelativeLocation))
				{
					return true;
				}
			}

			return false;
		}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:39,代码来源:STableViewTesting.cpp

示例4: ReadAndStoreSaveFileURL

/**
* This function parses the Json response after uploading the save file to obtain the 
* URL of the save file.
*
* @param JsonString              Json string to parse
* @param PlayerControllerId      Player controller ID of the player who is saving the file
*
*/
void CloudyWebConnectorImpl::ReadAndStoreSaveFileURL(FString JsonString, int32 PlayerControllerId)
{
    JsonString = JsonString.Replace(TEXT("["), TEXT(""));
    JsonString = JsonString.Replace(TEXT("]"), TEXT(""));
    
    TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
    TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonString);
    FJsonSerializer::Deserialize(JsonReader, JsonObject);

    // More player controllers than the TArray size
    if (PlayerControllerId >= SaveFileUrls.Num())
    {
        SaveFileUrls.AddUninitialized(PlayerControllerId - SaveFileUrls.Num() + 1);
    }
    if (JsonObject->HasField("saved_file"))
    {
        UE_LOG(CloudyWebConnectorLog, Error, TEXT("Json saved_file field found."));
        SaveFileUrls.Insert(JsonObject->GetStringField("saved_file"), PlayerControllerId);
    }
    else
    {
        UE_LOG(CloudyWebConnectorLog, Error, TEXT("Json saved_file field NOT found."));
        SaveFileUrls.Insert("", PlayerControllerId);
    }
}
开发者ID:cxmlg,项目名称:CloudyGamePlugin,代码行数:33,代码来源:CloudyWebConnector.cpp

示例5: AddLabelExpansion

void CSystemCreateStats::AddLabelExpansion (const CString &sAttributes, const CString &sPrefix)

//	AddLabelExpansion
//
//	Expands and adds the given attributes to the label counter

	{
	int i;

	TArray<CString> Attribs;
	ParseAttributes(sAttributes, &Attribs);

	//	Add each of the attributes alone (and make a list of permutations)

	TArray<CString> Permutable;
	for (i = 0; i < Attribs.GetCount(); i++)
		{
		if (m_PermuteAttribs.Find(Attribs[i]))
			Permutable.Insert(Attribs[i]);
		else
			AddEntry(Attribs[i]);
		}

	//	Now add all permutations

	if (Permutable.GetCount() >= 1)
		AddEntryPermutations(NULL_STR, Permutable, 0);
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:28,代码来源:CSystemCreateStats.cpp

示例6: LoadFromXML

ALERROR CLevelTableOfItemGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load table from XML

	{
	int i;
	ALERROR error;

	for (i = 0; i < pDesc->GetContentElementCount(); i++)
		{
		CXMLElement *pEntry = pDesc->GetContentElement(i);
		SEntry *pNewEntry = m_Table.Insert();

		pNewEntry->sLevelFrequency = pEntry->GetAttribute(LEVEL_FREQUENCY_ATTRIB);

		pNewEntry->Count.LoadFromXML(pEntry->GetAttribute(COUNT_ATTRIB));
		if (pNewEntry->Count.IsEmpty())
			pNewEntry->Count.SetConstant(1);

		if (error = IItemGenerator::CreateFromXML(Ctx, pEntry, &pNewEntry->pEntry))
			return error;
		}

	m_iComputedLevel = -1;

	return NOERROR;
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:29,代码来源:CItemTable.cpp

示例7: AddRect

void CComplexArea::AddRect (TArray<SRect> &Array, int x, int y, int cxWidth, int cyHeight, int iRotation)

//	AddRect
//
//	Adds the rect

{
    int i;

    if (cxWidth <= 0 || cyHeight <= 0)
        return;

    //	See if we already have a rect like this

    for (i = 0; i < Array.GetCount(); i++)
    {
        SRect &Test = Array[i];
        if (Test.x == x
                && Test.y == y
                && Test.iRotation == iRotation
                && Test.cxWidth == cxWidth
                && Test.cyHeight == cyHeight)
            return;
    }

    //	Add it

    SRect *pRect = Array.Insert();
    pRect->x = x;
    pRect->y = y;
    pRect->cxWidth = cxWidth;
    pRect->cyHeight = cyHeight;
    pRect->iRotation = (iRotation > 0 ? (iRotation % 360) : 0);

    //	Add to bounds

    if (iRotation > 0)
    {
        int xLL = 0;
        int yLL = 0;

        int xLR, yLR;
        IntPolarToVector(iRotation, cxWidth, &xLR, &yLR);

        int xUL, yUL;
        IntPolarToVector(iRotation + 90, cyHeight, &xUL, &yUL);

        int xUR = xUL + xLR;
        int yUR = yUL + yLR;

        int xLeft = Min(Min(xLL, xLR), Min(xUL, xUR));
        int xRight = Max(Max(xLL, xLR), Max(xUL, xUR));
        int yTop = Max(Max(yLL, yLR), Max(yUL, yUR));
        int yBottom = Min(Min(yLL, yLR), Min(yUL, yUR));

        AddToBounds(x + xLeft, y + yTop, x + xRight, y + yBottom);
    }
    else
        AddToBounds(x, y + cyHeight, x + cxWidth, y);
}
开发者ID:bmer,项目名称:Mammoth,代码行数:60,代码来源:CComplexArea.cpp

示例8: Parse

bool FTimespan::Parse( const FString& TimespanString, FTimespan& OutTimespan )
{
	// @todo gmp: implement stricter FTimespan parsing; this implementation is too forgiving.
	FString TokenString = TimespanString.Replace(TEXT("."), TEXT(":"));

	bool Negative = TokenString.StartsWith(TEXT("-"));

	TokenString.ReplaceInline(TEXT("-"), TEXT(":"), ESearchCase::CaseSensitive);

	TArray<FString> Tokens;
	TokenString.ParseIntoArray(Tokens, TEXT(":"), true);

	if (Tokens.Num() == 4)
	{
		Tokens.Insert(TEXT("0"), 0);
	}

	if (Tokens.Num() == 5)
	{
		OutTimespan.Assign(FCString::Atoi(*Tokens[0]), FCString::Atoi(*Tokens[1]), FCString::Atoi(*Tokens[2]), FCString::Atoi(*Tokens[3]), FCString::Atoi(*Tokens[4]));

		if (Negative)
		{
			OutTimespan.Ticks *= -1;
		}

		return true;
	}

	return false;
}
开发者ID:frobro98,项目名称:UnrealSource,代码行数:31,代码来源:Timespan.cpp

示例9: Subtract

void CSpaceObjectList::Subtract (const CSpaceObjectList &List)

//	Subtract
//
//	Removes all objects in List from the current list

	{
	int i;

	//	Mark all current objects

	int iCount = GetCount();
	for (i = 0; i < iCount; i++)
		GetObj(i)->SetMarked(true);

	//	Clear marks on all objects to remove

	for (i = 0; i < List.GetCount(); i++)
		List.GetObj(i)->SetMarked(false);

	//	Create a new list with the remaining objects

	TArray<CSpaceObject *> NewList;
	for (i = 0; i < iCount; i++)
		if (GetObj(i)->IsMarked())
			NewList.Insert(GetObj(i));

	m_List.TakeHandoff(NewList);
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:29,代码来源:CSpaceObjectList.cpp

示例10: LoadFromXML

ALERROR CGroupOfDeviceGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load from XML

	{
	int i;
	ALERROR error;

	m_Count.LoadFromXML(pDesc->GetAttribute(COUNT_ATTRIB));
	if (m_Count.IsEmpty())
		m_Count.SetConstant(1);

	//	Load either a <DeviceSlot> element or another device generator.

	for (i = 0; i < pDesc->GetContentElementCount(); i++)
		{
		CXMLElement *pEntry = pDesc->GetContentElement(i);

		if (strEquals(pEntry->GetTag(), DEVICE_SLOT_TAG))
			{
			SSlotDesc *pSlotDesc = m_SlotDesc.Insert();

			CItem::ParseCriteria(pEntry->GetAttribute(CRITERIA_ATTRIB), &pSlotDesc->Criteria);

			if (error = IDeviceGenerator::InitDeviceDescFromXML(Ctx, pEntry, &pSlotDesc->DefaultDesc))
				return error;

			pSlotDesc->iMaxCount = pEntry->GetAttributeIntegerBounded(MAX_COUNT_ATTRIB, 0, -1, -1);
			}
		else
			{
			SEntry *pTableEntry = m_Table.Insert();

			pTableEntry->iChance = pEntry->GetAttributeIntegerBounded(CHANCE_ATTRIB, 0, -1, 100);
			if (error = IDeviceGenerator::CreateFromXML(Ctx, pEntry, &pTableEntry->pDevice))
				{
				pTableEntry->pDevice = NULL;
				return error;
				}
			}
		}

	return NOERROR;
	}
开发者ID:smileyninja,项目名称:Transcendence,代码行数:46,代码来源:CDeviceTable.cpp

示例11: RegisterMarkProc

void CDatum::RegisterMarkProc (MARKPROC fnProc)

//	RegisterMarkProc
//
//	Register a procedure that will mark data in use

	{
	g_MarkList.Insert(fnProc);
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:9,代码来源:CDatum.cpp

示例12: PropertyHandleToPropertyPath

void PropertyHandleToPropertyPath(const UClass* OwnerClass, const IPropertyHandle& InPropertyHandle, TArray<UProperty*>& PropertyPath)
{
	PropertyPath.Add(InPropertyHandle.GetProperty());
	TSharedPtr<IPropertyHandle> CurrentHandle = InPropertyHandle.GetParentHandle();
	while (CurrentHandle.IsValid() && CurrentHandle->GetProperty() != nullptr)
	{
		PropertyPath.Insert(CurrentHandle->GetProperty(), 0);
		CurrentHandle = CurrentHandle->GetParentHandle();
	}
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:10,代码来源:KeyPropertyParams.cpp

示例13: InsertMountPoint

	// This will insert a mount point at the head of the search chain (so it can overlap an existing mount point and win)
	void InsertMountPoint(const FString& RootPath, const FString& ContentPath)
	{
		// Make sure the content path is stored as a relative path, consistent with the other paths we have
		FString RelativeContentPath = IFileManager::Get().ConvertToRelativePath( *ContentPath );

		// Make sure the path ends in a trailing path separator.  We are expecting that in the InternalFilenameToLongPackageName code.
		if( !RelativeContentPath.EndsWith( TEXT( "/" ) ) )
		{
			RelativeContentPath += TEXT( "/" );
		}

		FPathPair Pair(RootPath, RelativeContentPath);
		ContentRootToPath.Insert(Pair, 0);
		ContentPathToRoot.Insert(Pair, 0);
		MountPointRootPaths.Add( RootPath );

		// Let subscribers know that a new content path was mounted
		FPackageName::OnContentPathMounted().Broadcast( RootPath, ContentPath );
	}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:20,代码来源:PackageName.cpp

示例14: AccumulateEnhancements

bool CDeviceClass::AccumulateEnhancements (CItemCtx &Device, CInstalledDevice *pTarget, TArray<CString> &EnhancementIDs, CItemEnhancementStack *pEnhancements)

//	AccumulateEnhancements
//
//	If this device can enhance pTarget, then we add to the list of enhancements.

	{
	int i;
	bool bEnhanced = false;

	CInstalledDevice *pDevice = Device.GetDevice();
	CSpaceObject *pSource = Device.GetSource();

	//	See if we can enhance the target device

	if (pDevice == NULL 
			|| (pDevice->IsEnabled() && !pDevice->IsDamaged()))
		{
		for (i = 0; i < m_Enhancements.GetCount(); i++)
			{
			//	If this type of enhancement has already been applied, skip it

			if (!m_Enhancements[i].sType.IsBlank()
					&& EnhancementIDs.Find(m_Enhancements[i].sType))
				continue;

			//	If we don't match the criteria, skip it.

			if (pSource 
					&& pTarget
					&& !pSource->GetItemForDevice(pTarget).MatchesCriteria(m_Enhancements[i].Criteria))
				continue;

			//	Add the enhancement

			pEnhancements->Insert(m_Enhancements[i].Enhancement);
			bEnhanced = true;

			//	Remember that we added this enhancement class

			if (!m_Enhancements[i].sType.IsBlank())
				EnhancementIDs.Insert(m_Enhancements[i].sType);
			}
		}

	//	Let sub-classes add their own

	if (OnAccumulateEnhancements(Device, pTarget, EnhancementIDs, pEnhancements))
		bEnhanced = true;

	//	Done

	return bEnhanced;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:54,代码来源:Devices.cpp

示例15: BuildCurveName

FName BuildCurveName( TSharedPtr<FSectionKeyAreaNode> KeyAreaNode )
{
	FString CurveName;
	TSharedPtr<FSequencerDisplayNode> CurrentNameNode = KeyAreaNode;
	TArray<FString> NameParts;
	while ( CurrentNameNode.IsValid() )
	{
		NameParts.Insert( CurrentNameNode->GetDisplayName().ToString(), 0);
		CurrentNameNode = CurrentNameNode->GetParent();
	}
	return FName(*FString::Join(NameParts, TEXT(" - ")));
}
开发者ID:johndpope,项目名称:UE4,代码行数:12,代码来源:SequencerCurveOwner.cpp


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