本文整理汇总了C++中boost::circular_buffer::set_capacity方法的典型用法代码示例。如果您正苦于以下问题:C++ circular_buffer::set_capacity方法的具体用法?C++ circular_buffer::set_capacity怎么用?C++ circular_buffer::set_capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::circular_buffer
的用法示例。
在下文中一共展示了circular_buffer::set_capacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMark
void setMark(const LString &mark) {
m_bReady = true;
m_mark = mark;
m_nCbufLen = m_mark.length();
m_cbuf.set_capacity(m_nCbufLen);
m_nMatch = 0;
}
示例2: ShowFrameDurationPlot
void ShowFrameDurationPlot() {
Vec2i windowSize = mainApp->getWindow()->getSize();
size_t maxSamples = size_t(windowSize.x);
if(maxSamples != frameDurationPlotValues.capacity()) {
frameDurationPlotValues.set_capacity(maxSamples);
}
if(maxSamples != frameDurationPlotVertices.size()) {
frameDurationPlotVertices.resize(maxSamples);
}
GRenderer->ResetTexture(0);
frameDurationPlotValues.push_front(toMs(g_platformTime.lastFrameDuration()));
float avg = std::accumulate(frameDurationPlotValues.begin(), frameDurationPlotValues.end(), 0.f) / frameDurationPlotValues.size();
float worst = *std::max_element(frameDurationPlotValues.begin(), frameDurationPlotValues.end());
const float OFFSET_Y = 80.f;
const float SCALE_Y = 4.0f;
for(size_t i = 0; i < frameDurationPlotValues.size(); ++i)
{
float time = frameDurationPlotValues[i];
frameDurationPlotVertices[i].color = Color::white.toRGB();
frameDurationPlotVertices[i].p.x = i;
frameDurationPlotVertices[i].p.y = OFFSET_Y + (time * SCALE_Y);
frameDurationPlotVertices[i].p.z = 1.0f;
frameDurationPlotVertices[i].w = 1.0f;
}
EERIEDRAWPRIM(Renderer::LineStrip, &frameDurationPlotVertices[0], frameDurationPlotValues.size());
Color avgColor = Color::blue * 0.5f + Color::white * 0.5f;
float avgPos = OFFSET_Y + (avg * SCALE_Y);
drawLine(Vec2f(0, avgPos), Vec2f(windowSize.x, avgPos), 1.0f, Color::blue);
Color worstColor = Color::red * 0.5f + Color::white * 0.5f;
float worstPos = OFFSET_Y + (worst * SCALE_Y);
drawLine(Vec2f(0, worstPos), Vec2f(windowSize.x, worstPos), 1.0f, Color::red);
Font * font = hFontDebug;
float lineOffset = font->getLineHeight() + 2;
std::string labels[3] = { "Average: ", "Worst: ", "Current: " };
Color colors[3] = { avgColor, worstColor, Color::white };
float values[3] = { avg, worst, frameDurationPlotValues[0] };
std::string texts[3];
float widths[3];
static float labelWidth = 0.f;
static float valueWidth = 0.f;
for(size_t i = 0; i < 3; i++) {
// Format value
std::ostringstream oss;
oss << std::fixed << std::setprecision(2) << values[i] << " ms ("<< 1.f / (values[i] * 0.001f) << " FPS)";
texts[i] = oss.str();
// Calculate widths (could be done more efficiently for monospace fonts...)
labelWidth = std::max(labelWidth, float(font->getTextSize(labels[i]).width()));
widths[i] = font->getTextSize(texts[i]).width();
valueWidth = std::max(valueWidth, widths[i]);
}
float x = 10;
float y = 10;
float xend = x + labelWidth + 10 + valueWidth;
for(size_t i = 0; i < 3; i++) {
font->draw(Vec2i(x, y), labels[i], Color::gray(0.8f));
font->draw(Vec2i(xend - widths[i], y), texts[i], colors[i]);
y += lineOffset;
}
}