本文整理汇总了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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例11: RegisterMarkProc
void CDatum::RegisterMarkProc (MARKPROC fnProc)
// RegisterMarkProc
//
// Register a procedure that will mark data in use
{
g_MarkList.Insert(fnProc);
}
示例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();
}
}
示例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 );
}
示例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;
}
示例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(" - ")));
}