本文整理汇总了C++中JSONArray::count方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONArray::count方法的具体用法?C++ JSONArray::count怎么用?C++ JSONArray::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray::count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createRichTextMutation
RichTextMutation RandomMutationGenerator::createRichTextMutation(JSONObject object)
{
RichTextMutation m(true);
JSONArray text = object.attributeArray("_r");
// How many characters/objects are there?
int count = 0;
QHash<int, JSONAbstractObject> objects;
for( int j = 0; j < text.count(); ++j )
{
if ( text[j].isString())
count += text[j].toString().length();
else if ( !text[j].toObject().hasAttribute("_format"))
{
objects[count] = text[j];
count++;
}
}
int i = 0;
while( i < count )
{
int y = qrand() % 4;
if ( y == 0 )
{
m.content().append(SkipMutation(1));
i++;
}
else if ( y == 1)
{
m.content().append(DeleteMutation(1));
i++;
}
else if ( y == 2 && objects.contains(i))
{
m.content().append( createMutation( objects[i]) );
i++;
}
else
{
m.content().append( InsertMutation(createString()) );
}
}
return m;
}
示例2: createMutation
ArrayMutation RandomMutationGenerator::createMutation(JSONArray arr)
{
ArrayMutation m(true);
QList<int> liftPositions;
QList<int> arrPositions;
int i = 0;
while( i < arr.count() )
{
int y = qrand() % 7;
if ( y == 0 || y == 1 )
{
liftPositions.append( m.content().count() );
arrPositions.append(i);
m.content().append(SkipMutation(1));
i++;
}
else if ( y == 2 || y == 3 )
{
liftPositions.append( m.content().count() );
arrPositions.append(i);
m.content().append(DeleteMutation(1));
i++;
}
else if ( y == 4 || y == 5)
{
liftPositions.append( m.content().count() );
arrPositions.append(i);
m.content().append( createMutation(arr[i]));
i++;
}
else
{
m.content().append( InsertMutation(createString()) );
}
}
int counter = m_liftCount;
int lifts = qrand() % qMax(1, liftPositions.count() - 2);
m_liftCount += lifts;
// qDebug("Fuck %i", lifts);
for( int i = 0; i < lifts; i++ )
{
int pos = qrand() % liftPositions.count();
LiftMutation l( "AL" + QString::number(counter+i));
m.content().replace(liftPositions[pos], l);
if ( qrand() % 2 == 0 )
{
l.setMutation( createMutation(arr[arrPositions[pos]]) );
}
liftPositions.removeAt(pos);
arrPositions.removeAt(pos);
}
for( int i = 0; i < lifts; i++ )
{
int pos = qrand() % (m.content().count() + 1);
m.content().insert(pos, SqueezeMutation( "AL" + QString::number(counter+i)));
}
return m;
}