本文整理汇总了C++中CArray::getItLast方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::getItLast方法的具体用法?C++ CArray::getItLast怎么用?C++ CArray::getItLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::getItLast方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
// Launch unit test.
EUnitTestResult test()
{ CALL
CArray<Tsint> array;
CListDC<Tsint> circle;
CListDL<Tsint> list;
// Fill the array.
UT_ASSERT(array.insertLast(1));
UT_ASSERT(array.insertLast(2));
UT_ASSERT(array.insertLast(3));
UT_ASSERT(array.insertLast(4));
UT_ASSERT(array.insertLast(5));
UT_ASSERT(array.insertLast(6));
// Fill the double circled list.
UT_ASSERT(circle.insertCurrentForward(1));
UT_ASSERT(circle.insertNext(6));
UT_ASSERT(circle.insertNext(5));
UT_ASSERT(circle.insertNext(4));
UT_ASSERT(circle.insertNext(3));
UT_ASSERT(circle.insertNext(2));
// Fill the double linked list.
UT_ASSERT(list.insertLast(1));
UT_ASSERT(list.insertLast(2));
UT_ASSERT(list.insertLast(3));
UT_ASSERT(list.insertLast(4));
UT_ASSERT(list.insertLast(5));
UT_ASSERT(list.insertLast(6));
// Check counts.
UT_ASSERT_EQUAL(count(array), 6);
UT_ASSERT_EQUAL(countPrev(array.getItLast()), 6);
UT_ASSERT_EQUAL(countNext(boundItForward(array.getItIndex(1), array.getItIndex(4))), 4);
UT_ASSERT_EQUAL(countPrev(boundItBackward(array.getItIndex(3), array.getItIndex(2))), 2);
UT_ASSERT_EQUAL(count(circle), 6);
UT_ASSERT_EQUAL(countPrev(circle.getItCurrent().getBackward()), 6);
UT_ASSERT_EQUAL(count(list), 6);
UT_ASSERT_EQUAL(countPrev(list.getItLast()), 6);
// Check conditional counts.
UT_ASSERT_EQUAL(countIf(array, isOdd), 3);
UT_ASSERT_EQUAL(countIfPrev(array.getItLast(), isOdd), 3);
UT_ASSERT_EQUAL(countIfNext(boundItForward(array.getItIndex(1), array.getItIndex(4)), isOdd), 2);
UT_ASSERT_EQUAL(countIfPrev(boundItBackward(array.getItIndex(3), array.getItIndex(2)), isOdd), 1);
UT_ASSERT_EQUAL(countIf(circle, isOdd), 3);
UT_ASSERT_EQUAL(countIfPrev(circle.getItCurrent().getBackward(), isOdd), 3);
UT_ASSERT_EQUAL(countIf(list, isOdd), 3);
UT_ASSERT_EQUAL(countIfPrev(list.getItLast(), isOdd), 3);
UT_ACCEPT;
}
示例2: UT_ASSERT_CHECK_REMOVE
// Check the remove functionality of the CArray<Tsint>.
void UT_ASSERT_CHECK_REMOVE(CArray<Tsint>& a_rArray, Tbool a_cDirectOrder, const Tbool a_cReversed = false)
{ CALL
Tsint value = (a_cDirectOrder || a_cReversed) ? 1 : 6;
CArray<Tsint>::TIterator it = (a_cDirectOrder ? a_rArray.getItFirst() : a_rArray.getItLast());
while (it.isValid())
{
UT_ASSERT_EQUAL(*it, value);
(a_cDirectOrder || a_cReversed) ? ++value : --value;
UT_ASSERT(a_cDirectOrder ? it.removeForward() : it.removeBackward());
}
UT_ASSERT_EQUAL(value, ((a_cDirectOrder || a_cReversed) ? 7 : 0));
}
示例3: UT_ASSERT_CHECK_REMOVE
// Check the remove functionality of the CArray<Tbool>.
void UT_ASSERT_CHECK_REMOVE(CArray<Tbool>& a_rArray, Tbool a_cDirectOrder, const Tbool a_cReversed = false)
{ CALL
Tbool value = (a_cDirectOrder || a_cReversed) ? true : false;
CArray<Tbool>::TIterator it = (a_cDirectOrder ? a_rArray.getItFirst() : a_rArray.getItLast());
while (it.isValid())
{
UT_ASSERT_EQUAL(*it, value);
value = !value;
UT_ASSERT(a_cDirectOrder ? it.removeForward() : it.removeBackward());
}
UT_ASSERT((a_cDirectOrder || a_cReversed) ? (value == true) : (value == false));
}
示例4: remove
// Remove all items from the instance of the CArray<Tbool> class.
static void remove(IWriter& writer, CArray<Tbool>& a_rArray, const Tbool a_cDirectOrder)
{ CALL
writer << STR("CArray<Tbool>(") << STR("size = ") << a_rArray.getSize() << STR(")") << ln;
CArray<Tbool>::TIterator it = (a_cDirectOrder ? a_rArray.getItFirst() : a_rArray.getItLast());
writer << STR("{") << ln;
while (it.isValid())
{
writer << STR(" removed item = ") << *it << ln;
a_cDirectOrder ? it.removeForward() : it.removeBackward();
}
writer << STR("}") << ln;
}
示例5: UT_ASSERT_CHECK_SHOW_REVERSED
// Check the show reversed functionality of the CArray<Tsint>.
void UT_ASSERT_CHECK_SHOW_REVERSED(const CArray<Tsint>& a_crArray, const Tbool a_cDirectOrder)
{ CALL
Tsint value = (a_cDirectOrder ? 6 : 1);
CArray<Tsint>::TIteratorConst it = (a_cDirectOrder ? a_crArray.getItFirst() : a_crArray.getItLast());
if (it.isValid())
{
do
{
UT_ASSERT_EQUAL(*it, value);
(a_cDirectOrder) ? --value : ++value;
} while ((a_cDirectOrder ? it.stepForward() : it.stepBackward()) == 1);
}
UT_ASSERT_EQUAL(value, (a_cDirectOrder ? 0 : 7));
}
示例6: UT_ASSERT_CHECK_SHOW_REVERSED
// Check the show reversed functionality of the CArray<Tbool>.
void UT_ASSERT_CHECK_SHOW_REVERSED(const CArray<Tbool>& a_crArray, const Tbool a_cDirectOrder)
{ CALL
Tbool value = (a_cDirectOrder ? false : true);
CArray<Tbool>::TIteratorConst it = (a_cDirectOrder ? a_crArray.getItFirst() : a_crArray.getItLast());
if (it.isValid())
{
do
{
UT_ASSERT_EQUAL(*it, value);
value = !value;
} while ((a_cDirectOrder ? it.stepForward() : it.stepBackward()) == 1);
}
UT_ASSERT((a_cDirectOrder) ? !value : value);
}
示例7: test
// Launch unit test.
EUnitTestResult test()
{ CALL
CArray<Tsint> array;
CListDC<Tsint> circle;
CListDL<Tsint> list;
// Fill the array.
UT_ASSERT(array.insertLast(1));
UT_ASSERT(array.insertLast(2));
UT_ASSERT(array.insertLast(3));
UT_ASSERT(array.insertLast(4));
UT_ASSERT(array.insertLast(5));
UT_ASSERT(array.insertLast(6));
// Fill the double circled list.
UT_ASSERT(circle.insertCurrentForward(1));
UT_ASSERT(circle.insertNext(6));
UT_ASSERT(circle.insertNext(5));
UT_ASSERT(circle.insertNext(4));
UT_ASSERT(circle.insertNext(3));
UT_ASSERT(circle.insertNext(2));
// Fill the double linked list.
UT_ASSERT(list.insertLast(1));
UT_ASSERT(list.insertLast(2));
UT_ASSERT(list.insertLast(3));
UT_ASSERT(list.insertLast(4));
UT_ASSERT(list.insertLast(5));
UT_ASSERT(list.insertLast(6));
// Check upper bounds.
UT_ASSERT(!upperBound(array, CONSTS(0)).isValid());
UT_ASSERT_EQUAL(upperBound(array, CONSTS(1)).getValueRef(), 1);
UT_ASSERT_EQUAL(upperBound(array, CONSTS(4)).getValueRef(), 4);
UT_ASSERT_EQUAL(upperBound(array, CONSTS(6)).getValueRef(), 6);
UT_ASSERT_EQUAL(upperBound(array, CONSTS(8)).getValueRef(), 6);
UT_ASSERT(!upperBoundPrev(array.getItLast(), CONSTS(0)).isValid());
UT_ASSERT_EQUAL(upperBoundPrev(array.getItLast(), CONSTS(1)).getValueRef(), 1);
UT_ASSERT_EQUAL(upperBoundPrev(array.getItLast(), CONSTS(4)).getValueRef(), 4);
UT_ASSERT_EQUAL(upperBoundPrev(array.getItLast(), CONSTS(6)).getValueRef(), 6);
UT_ASSERT_EQUAL(upperBoundPrev(array.getItLast(), CONSTS(8)).getValueRef(), 6);
UT_ASSERT(!upperBound(circle, CONSTS(0)).isValid());
UT_ASSERT_EQUAL(upperBound(circle, CONSTS(1)).getValueRef(), 1);
UT_ASSERT_EQUAL(upperBound(circle, CONSTS(4)).getValueRef(), 4);
UT_ASSERT_EQUAL(upperBound(circle, CONSTS(6)).getValueRef(), 6);
UT_ASSERT_EQUAL(upperBound(circle, CONSTS(8)).getValueRef(), 6);
UT_ASSERT(!upperBoundPrev(circle.getItCurrent().getBackward(), CONSTS(0)).isValid());
UT_ASSERT_EQUAL(upperBoundPrev(circle.getItCurrent().getBackward(), CONSTS(1)).getValueRef(), 1);
UT_ASSERT_EQUAL(upperBoundPrev(circle.getItCurrent().getBackward(), CONSTS(4)).getValueRef(), 4);
UT_ASSERT_EQUAL(upperBoundPrev(circle.getItCurrent().getBackward(), CONSTS(6)).getValueRef(), 6);
UT_ASSERT_EQUAL(upperBoundPrev(circle.getItCurrent().getBackward(), CONSTS(8)).getValueRef(), 6);
UT_ASSERT(!upperBound(list, CONSTS(0)).isValid());
UT_ASSERT_EQUAL(upperBound(list, CONSTS(1)).getValueRef(), 1);
UT_ASSERT_EQUAL(upperBound(list, CONSTS(4)).getValueRef(), 4);
UT_ASSERT_EQUAL(upperBound(list, CONSTS(6)).getValueRef(), 6);
UT_ASSERT_EQUAL(upperBound(list, CONSTS(8)).getValueRef(), 6);
UT_ASSERT(!upperBoundPrev(list.getItLast(), CONSTS(0)).isValid());
UT_ASSERT_EQUAL(upperBoundPrev(list.getItLast(), CONSTS(1)).getValueRef(), 1);
UT_ASSERT_EQUAL(upperBoundPrev(list.getItLast(), CONSTS(4)).getValueRef(), 4);
UT_ASSERT_EQUAL(upperBoundPrev(list.getItLast(), CONSTS(6)).getValueRef(), 6);
UT_ASSERT_EQUAL(upperBoundPrev(list.getItLast(), CONSTS(8)).getValueRef(), 6);
UT_ACCEPT;
}