本文整理汇总了C++中CArray::insertLast方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::insertLast方法的具体用法?C++ CArray::insertLast怎么用?C++ CArray::insertLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::insertLast方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
Tsint main(const CStringBuffer<CString>& a_crArguments, const CStringBuffer<CString>& a_crEnvironment)
{ CALL
IGNORE_UNUSED(a_crArguments);
IGNORE_UNUSED(a_crEnvironment);
// Use standard output stream of the current process.
CStreamStdOutput stdoutput(true);
CArray<Tbool> a;
// Fill the array.
a.insertFirst(false);
a.insertFirst(true);
a.insertLast(false);
a.insertLast(true);
a.insertIndex(2, true);
// Show the array.
stdoutput << a;
// Copy the array.
CArray<Tbool> b(a);
// Reverse the array.
b.reverse();
// Show the reversed array.
stdoutput << b;
// Remove items from arrays.
remove(stdoutput, a, true);
remove(stdoutput, b, false);
return IApplication::EXIT_WITH_SUCCESS;
}
示例2: UT_ASSERT_CHECK_FILL
// Check the fill functionality of the CArray<Tsint>.
void UT_ASSERT_CHECK_FILL(CArray<Tsint>& a_rArray, const Tbool a_cDirectOrder)
{ CALL
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(6) : a_rArray.insertLast(1));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(5) : a_rArray.insertLast(2));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(4) : a_rArray.insertLast(3));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(3) : a_rArray.insertLast(4));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(2) : a_rArray.insertLast(5));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(1) : a_rArray.insertLast(6));
}
示例3: 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;
}
示例4: UT_ASSERT_CHECK_FILL
// Check the fill functionality of the CArray<Tbool>.
void UT_ASSERT_CHECK_FILL(CArray<Tbool>& a_rArray, const Tbool a_cDirectOrder)
{ CALL
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(false) : a_rArray.insertLast(true));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(true) : a_rArray.insertLast(false));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(false) : a_rArray.insertLast(true));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(true) : a_rArray.insertLast(false));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(false) : a_rArray.insertLast(true));
UT_ASSERT(a_cDirectOrder ? a_rArray.insertFirst(true) : a_rArray.insertLast(false));
}
示例5: test
// Launch unit test.
EUnitTestResult test()
{ CALL
CArray<Tsint> array;
CListDC<Tsint> circle1, circle2, circle3, circle4, circleCopy;
CListDL<Tsint> list1, list2, list3, list4, listCopy;
// Fill the array.
UT_ASSERT(array.insertLast(4));
UT_ASSERT(array.insertLast(6));
UT_ASSERT(array.insertLast(3));
UT_ASSERT(array.insertLast(1));
UT_ASSERT(array.insertLast(5));
UT_ASSERT(array.insertLast(2));
// Copy the array into the double circled list and bubble sort it.
UT_ASSERT_EQUAL(copy(array, circle1), 6);
UT_ASSERT(sortBubble(circle1));
UT_ASSERT_CHECK_LIST(circle1);
// Copy the array into the double linked list and bubble sort it.
UT_ASSERT_EQUAL(copy(array, list1), 6);
UT_ASSERT(sortBubble(list1));
UT_ASSERT_CHECK_LIST(list1);
// Copy the array into the double circled list and minimal choose sort it.
UT_ASSERT_EQUAL(copy(array, circle2), 6);
UT_ASSERT(sortChoose(circle2));
UT_ASSERT_CHECK_LIST(circle2);
// Copy the array into the double linked list and minimal choose sort it.
UT_ASSERT_EQUAL(copy(array, list2), 6);
UT_ASSERT(sortChoose(list2));
UT_ASSERT_CHECK_LIST(list2);
// Copy the array into the double circled list and shell sort it.
UT_ASSERT_EQUAL(copy(array, circle3), 6);
UT_ASSERT(sortShell(circle3));
UT_ASSERT_CHECK_LIST(circle3);
// Copy the array into the double linked list and shell sort it.
UT_ASSERT_EQUAL(copy(array, list3), 6);
UT_ASSERT(sortShell(list3));
UT_ASSERT_CHECK_LIST(list3);
// Copy the array into the double circled list and quick sort it.
UT_ASSERT_EQUAL(copy(array, circle4), 6);
UT_ASSERT(sortQuick(circle4));
UT_ASSERT_CHECK_LIST(circle4);
// Copy the array into the double linked list and quick sort it.
UT_ASSERT_EQUAL(copy(array, list4), 6);
UT_ASSERT(sortQuick(list4));
UT_ASSERT_CHECK_LIST(list4);
// Sort the array and copy it into the double circled list.
UT_ASSERT_EQUAL(sortCopy(array, circleCopy), 6);
UT_ASSERT_EQUAL(circleCopy.stepForward(3), 3);
UT_ASSERT_CHECK_LIST(circleCopy);
// Sort the array and copy it into the double linked list.
UT_ASSERT_EQUAL(sortCopy(array, listCopy), 6);
UT_ASSERT_CHECK_LIST(listCopy);
UT_ACCEPT;
}
示例6: 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;
}