当前位置: 首页>>代码示例>>C++>>正文


C++ BoundedBuffer::front方法代码示例

本文整理汇总了C++中BoundedBuffer::front方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundedBuffer::front方法的具体用法?C++ BoundedBuffer::front怎么用?C++ BoundedBuffer::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundedBuffer的用法示例。


在下文中一共展示了BoundedBuffer::front方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_buffer_fronts_in_sequence_of_push_pop

void test_buffer_fronts_in_sequence_of_push_pop() {
	BoundedBuffer<int> buffer { 5 };
	std::vector<int> frontValues { }, expectedValues { 1, 1, 1, 2, 2, 3, 4, 4, 5 };
	buffer.push(1);
	frontValues.push_back(buffer.front());
	buffer.push(2);
	frontValues.push_back(buffer.front());
	buffer.push(3);
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.push(4);
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.push(5);
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	ASSERT_EQUAL(expectedValues, frontValues);
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:23,代码来源:bounded_buffer_content_suite.cpp

示例2: test_buffer_front_throws_after_push_pop

void test_buffer_front_throws_after_push_pop() {
	BoundedBuffer<int> buffer { 5 };
	buffer.push(5);
	buffer.pop();
	ASSERT_THROWS(buffer.front(), std::logic_error);
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:6,代码来源:bounded_buffer_content_suite.cpp

示例3: test_buffer_front_gets_first_element_of_pushs

void test_buffer_front_gets_first_element_of_pushs() {
	BoundedBuffer<int> buffer { 5 };
	buffer.push(1);
	buffer.push(2);
	ASSERT_EQUAL(1, buffer.front());
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:6,代码来源:bounded_buffer_content_suite.cpp

示例4: test_buffer_front_gets_element_of_push

void test_buffer_front_gets_element_of_push() {
	BoundedBuffer<int> buffer { 5 };
	buffer.push(5);
	ASSERT_EQUAL(5, buffer.front());
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:5,代码来源:bounded_buffer_content_suite.cpp

示例5: test_buffer_wrap_around_behavior_front

void test_buffer_wrap_around_behavior_front() {
	BoundedBuffer<int> buffer { 3 };
	std::vector<int> frontValues { }, expectedValues { 1, 1, 2, 2, 2, 3, 4, 4, 5, 5, 5, 6, 7 };
	buffer.push(1);
	frontValues.push_back(buffer.front());
	buffer.push(2);
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.push(3);
	frontValues.push_back(buffer.front());
	buffer.push(4);
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.push(5);
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.push(6);
	frontValues.push_back(buffer.front());
	buffer.push(7);
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	buffer.pop();
	frontValues.push_back(buffer.front());
	ASSERT_EQUAL(expectedValues, frontValues);
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:31,代码来源:bounded_buffer_content_suite.cpp

示例6: test_make_bounded_buffer_from_two_mixed_arguments_first_element_moved

void test_make_bounded_buffer_from_two_mixed_arguments_first_element_moved() {
	MemoryOperationCounter expected{1, 0, true};
	MemoryOperationCounter lvalue{};
	BoundedBuffer<MemoryOperationCounter> buffer = BoundedBuffer<MemoryOperationCounter>::make_buffer(MemoryOperationCounter{}, lvalue);
	ASSERT_EQUAL(expected, buffer.front());
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:6,代码来源:bounded_buffer_make_buffer_suite.cpp

示例7: test_make_bounded_buffer_from_two_rvalue_arguments_first_element_copied

void test_make_bounded_buffer_from_two_rvalue_arguments_first_element_copied() {
	MemoryOperationCounter expected{0, 1, true};
	MemoryOperationCounter lvalue{};
	BoundedBuffer<MemoryOperationCounter> buffer = BoundedBuffer<MemoryOperationCounter>::make_buffer(lvalue, MemoryOperationCounter{});
	ASSERT_EQUAL(expected, buffer.front());
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:6,代码来源:bounded_buffer_make_buffer_suite.cpp

示例8: test_bounded_buffer_constructed_with_const_lvalue_argument_object_copied

void test_bounded_buffer_constructed_with_const_lvalue_argument_object_copied() {
	MemoryOperationCounter expected{0, 1, true};
	MemoryOperationCounter const insertee{};
	BoundedBuffer<MemoryOperationCounter> buffer = BoundedBuffer<MemoryOperationCounter>::make_buffer(insertee);
	ASSERT_EQUAL(expected, buffer.front());
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:6,代码来源:bounded_buffer_make_buffer_suite.cpp

示例9: test_make_bounded_buffer_from_rvalue_argument_object_moved

void test_make_bounded_buffer_from_rvalue_argument_object_moved() {
	MemoryOperationCounter expected{1, 0, true};
	BoundedBuffer<MemoryOperationCounter> buffer = BoundedBuffer<MemoryOperationCounter>::make_buffer(MemoryOperationCounter{});
	ASSERT_EQUAL(expected, buffer.front());
}
开发者ID:paddor,项目名称:cpp-advanced-exercises,代码行数:5,代码来源:bounded_buffer_make_buffer_suite.cpp


注:本文中的BoundedBuffer::front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。