本文整理汇总了C++中Coordinates::count方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinates::count方法的具体用法?C++ Coordinates::count怎么用?C++ Coordinates::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinates
的用法示例。
在下文中一共展示了Coordinates::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void Coordinates_test::
t_readonly()
{
Coordinates c;
QCOMPARE(c.size(), 0u);
QCOMPARE(c.count(), 0);
QVERIFY(c.isEmpty());
c << 1.0 << -2.0;
QCOMPARE(c.size(), 2u);
QCOMPARE(c.count(), 2);
QVERIFY(!c.isEmpty());
}//t_readonly
示例2: QCOMPARE
void Coordinates_test::
t_convert()
{
Coordinates c;
c << 1.0 << 3.0;
QCOMPARE(c.data()[1], 3.0);
coordT *c2= c.data();
const coordT *c3= c.data();
QCOMPARE(c2, c3);
std::vector<coordT> vc= c.toStdVector();
QCOMPARE(vc.size(), c.size());
for(size_t k= vc.size(); k--; ){
QCOMPARE(vc[k], c[k]);
}
QList<coordT> qc= c.toQList();
QCOMPARE(qc.count(), c.count());
for(int k= qc.count(); k--; ){
QCOMPARE(qc[k], c[k]);
}
Coordinates c4;
c4= std::vector<double>(2, 0.0);
QCOMPARE(c4.back(), 0.0);
Coordinates c5(std::vector<double>(2, 0.0));
QCOMPARE(c4.size(), c5.size());
QVERIFY(c4==c5);
}//t_convert
示例3: QVERIFY
void Coordinates_test::
t_search()
{
Coordinates c;
c << 1.0 << 3.0 << 1.0;
QVERIFY(c.contains(1.0));
QVERIFY(c.contains(3.0));
QVERIFY(!c.contains(0.0));
QCOMPARE(c.count(1.0), 2);
QCOMPARE(c.count(3.0), 1);
QCOMPARE(c.count(0.0), 0);
QCOMPARE(c.indexOf(1.0), 0);
QCOMPARE(c.indexOf(3.0), 1);
QCOMPARE(c.indexOf(1.0, -1), 2);
QCOMPARE(c.indexOf(3.0, -1), -1);
QCOMPARE(c.indexOf(3.0, -2), 1);
QCOMPARE(c.indexOf(1.0, -3), 0);
QCOMPARE(c.indexOf(1.0, -4), 0);
QCOMPARE(c.indexOf(1.0, 1), 2);
QCOMPARE(c.indexOf(3.0, 2), -1);
QCOMPARE(c.indexOf(1.0, 2), 2);
QCOMPARE(c.indexOf(1.0, 3), -1);
QCOMPARE(c.indexOf(1.0, 4), -1);
QCOMPARE(c.lastIndexOf(1.0), 2);
QCOMPARE(c.lastIndexOf(3.0), 1);
QCOMPARE(c.lastIndexOf(1.0, -1), 2);
QCOMPARE(c.lastIndexOf(3.0, -1), 1);
QCOMPARE(c.lastIndexOf(3.0, -2), 1);
QCOMPARE(c.lastIndexOf(1.0, -3), 0);
QCOMPARE(c.lastIndexOf(1.0, -4), -1);
QCOMPARE(c.lastIndexOf(1.0, 1), 0);
QCOMPARE(c.lastIndexOf(3.0, 2), 1);
QCOMPARE(c.lastIndexOf(1.0, 2), 2);
QCOMPARE(c.lastIndexOf(1.0, 3), 2);
QCOMPARE(c.lastIndexOf(1.0, 4), 2);
c.removeAll(3.0);
QCOMPARE(c.count(), 2);
c.removeAll(4.0);
QCOMPARE(c.count(), 2);
c.removeAll(1.0);
QCOMPARE(c.count(), 0);
c.removeAll(4.0);
QCOMPARE(c.count(), 0);
}//t_search
示例4: i
void Coordinates_test::
t_mutable_coord_iterator()
{
// Same tests as CoordinatesIterator
Coordinates c;
c << 1.0 << 3.0;
MutableCoordinatesIterator i(c);
MutableCoordinatesIterator i2= c;
QVERIFY(i.findNext(1.0));
QVERIFY(!i.findNext(2.0));
QVERIFY(!i.findNext(3.0));
QVERIFY(i.findPrevious(3.0));
QVERIFY(!i.findPrevious(2.0));
QVERIFY(!i.findPrevious(1.0));
QVERIFY(i2.findNext(3.0));
QVERIFY(i2.findPrevious(3.0));
QVERIFY(i2.findNext(3.0));
QVERIFY(i2.findPrevious(1.0));
QVERIFY(i2.hasNext());
QVERIFY(!i2.hasPrevious());
QVERIFY(i.hasNext());
QVERIFY(!i.hasPrevious());
i.toBack();
i2.toFront();
QVERIFY(!i.hasNext());
QVERIFY(i.hasPrevious());
QVERIFY(i2.hasNext());
QVERIFY(!i2.hasPrevious());
Coordinates c2;
i2= c2;
QVERIFY(!i2.hasNext());
QVERIFY(!i2.hasPrevious());
i2.toBack();
QVERIFY(!i2.hasNext());
QVERIFY(!i2.hasPrevious());
QCOMPARE(i.peekPrevious(), 3.0);
QCOMPARE(i.peekPrevious(), 3.0);
QCOMPARE(i.previous(), 3.0);
QCOMPARE(i.previous(), 1.0);
QVERIFY(!i.hasPrevious());
QCOMPARE(i.peekNext(), 1.0);
QCOMPARE(i.next(), 1.0);
QCOMPARE(i.peekNext(), 3.0);
QCOMPARE(i.next(), 3.0);
QVERIFY(!i.hasNext());
i.toFront();
QCOMPARE(i.next(), 1.0);
// Mutable tests
i.toFront();
i.peekNext()= -1.0;
QCOMPARE(i.peekNext(), -1.0);
QCOMPARE((i.next()= 1.0), 1.0);
QCOMPARE(i.peekPrevious(), 1.0);
i.remove();
QCOMPARE(c.count(), 1);
i.remove();
QCOMPARE(c.count(), 1);
QCOMPARE(i.peekNext(), 3.0);
i.insert(1.0);
i.insert(2.0);
QCOMPARE(c.count(), 3);
QCOMPARE(i.peekNext(), 3.0);
QCOMPARE(i.peekPrevious(), 2.0);
i.peekPrevious()= -2.0;
QCOMPARE(i.peekPrevious(), -2.0);
QCOMPARE((i.previous()= 2.0), 2.0);
QCOMPARE(i.peekNext(), 2.0);
i.toBack();
i.remove();
QCOMPARE(c.count(), 3); // unchanged
i.toFront();
i.remove();
QCOMPARE(c.count(), 3); // unchanged
QCOMPARE(i.peekNext(), 1.0);
i.remove();
QCOMPARE(c.count(), 3); // unchanged
i.insert(0.0);
QCOMPARE(c.count(), 4);
QCOMPARE(i.value(), 0.0);
QCOMPARE(i.peekPrevious(), 0.0);
i.setValue(-10.0);
QCOMPARE(c.count(), 4); // unchanged
QCOMPARE(i.peekNext(), 1.0);
QCOMPARE(i.peekPrevious(), -10.0);
i.findNext(1.0);
i.setValue(-1.0);
QCOMPARE(i.peekPrevious(), -1.0);
i.setValue(1.0);
QCOMPARE(i.peekPrevious(), 1.0);
QCOMPARE(i.value(), 1.0);
i.findPrevious(1.0);
i.setValue(-1.0);
QCOMPARE(i.peekNext(), -1.0);
i.toBack();
QCOMPARE(i.previous(), 3.0);
i.setValue(-3.0);
QCOMPARE(i.peekNext(), -3.0);
double d= i.value();
QCOMPARE(d, -3.0);
//.........这里部分代码省略.........