本文整理汇总了C++中JArray::InsertElementAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ JArray::InsertElementAtIndex方法的具体用法?C++ JArray::InsertElementAtIndex怎么用?C++ JArray::InsertElementAtIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArray
的用法示例。
在下文中一共展示了JArray::InsertElementAtIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
GRaggedFloatTableData::InsertCol
(
const JIndex index,
const JOrderedSet<JFloat>* initData
)
{
JIndex trueIndex = index;
const JIndex maxIndex = itsCols->GetElementCount()+1;
if (trueIndex > maxIndex)
{
trueIndex = maxIndex;
}
JArray<JFloat>* colData = jnew JArray<JFloat>;
assert( colData != NULL );
itsCols->InsertAtIndex(trueIndex, colData);
if (initData != NULL)
{
const JSize rowCount = initData->GetElementCount();
for (JIndex i=1; i<=rowCount; i++)
{
colData->InsertElementAtIndex(i, initData->GetElement(i));
}
}
ColsAdded(1);
if (itsBroadcast)
{
Broadcast(JTableData::ColsInserted(trueIndex, 1));
}
}
示例2:
JBoolean
JPartition::InsertCompartment
(
const JIndex index,
const JCoordinate reqSize,
const JCoordinate minSize
)
{
JArray<JCoordinate> newSizes;
JCoordinate trueSize;
if (CreateSpace(*itsSizes, *itsMinSizes, itsElasticIndex,
reqSize + kDragRegionSize, minSize + kDragRegionSize,
&newSizes, &trueSize))
{
trueSize -= kDragRegionSize;
JCoordinate position = 0;
for (JIndex i=1; i<index; i++)
{
position += newSizes.GetElement(i) + kDragRegionSize;
}
CreateCompartmentObject(index, position, trueSize);
newSizes.InsertElementAtIndex(index, trueSize);
itsMinSizes->InsertElementAtIndex(index, minSize);
if (index <= itsElasticIndex)
{
itsElasticIndex++;
}
*itsSizes = newSizes;
SetCompartmentSizes();
return kJTrue;
}
else
{
return kJFalse;
}
}