本文整理汇总了C++中StaticArray::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ StaticArray::empty方法的具体用法?C++ StaticArray::empty怎么用?C++ StaticArray::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StaticArray
的用法示例。
在下文中一共展示了StaticArray::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Move
void Move(const PixelRect &rc) override {
const Layout layout(rc, waypoint);
if (allow_navigation)
goto_button.Move(layout.goto_button);
if (!images.empty()) {
magnify_button.Move(layout.magnify_button);
shrink_button.Move(layout.shrink_button);
}
if (allow_navigation) {
previous_button.Move(layout.previous_button);
next_button.Move(layout.next_button);
}
close_button.Move(layout.close_button);
info_dock.Move(layout.main);
details_panel.Move(layout.main);
details_text.Move(layout.details_text);
#ifdef HAVE_RUN_FILE
if (!waypoint.files_external.empty())
file_list.Move(layout.file_list);
#endif
commands_dock.Move(layout.main);
if (!images.empty())
image_window.Move(layout.main);
}
示例2: Show
void Show(const PixelRect &rc) override {
const Layout layout(rc, *waypoint);
if (task_manager != nullptr)
goto_button.MoveAndShow(layout.goto_button);
if (!images.empty()) {
magnify_button.MoveAndShow(layout.magnify_button);
shrink_button.MoveAndShow(layout.shrink_button);
}
previous_button.MoveAndShow(layout.previous_button);
next_button.MoveAndShow(layout.next_button);
close_button.MoveAndShow(layout.close_button);
info_dock.Move(layout.main);
details_panel.Move(layout.main);
details_text.Move(layout.details_text);
#ifdef HAVE_RUN_FILE
if (!waypoint->files_external.empty())
file_list.Move(layout.file_list);
#endif
commands_dock.Move(layout.main);
if (!images.empty())
image_window.Move(layout.main);
UpdatePage();
}
示例3: Average
/**
* Calculate average from samples
*
* @return Average value in buffer
*/
gcc_pure
fixed Average() const {
assert(!x.empty());
fixed y = fixed_zero;
for (unsigned i = 0; i < x.size(); i++)
y += x[i];
return y / x.size();
}
示例4: Hide
void Hide() override {
if (task_manager != nullptr)
goto_button.Hide();
if (!images.empty()) {
magnify_button.Hide();
shrink_button.Hide();
}
previous_button.Hide();
next_button.Hide();
close_button.Hide();
info_dock.Hide();
details_panel.Hide();
commands_dock.Hide();
if (!images.empty())
image_window.Hide();
}
示例5: Hide
void Hide() override {
if (allow_navigation)
goto_button.Hide();
if (!images.empty()) {
magnify_button.Hide();
shrink_button.Hide();
}
if (allow_navigation) {
previous_button.Hide();
next_button.Hide();
}
close_button.Hide();
info_dock.Hide();
details_panel.Hide();
commands_dock.Hide();
if (!images.empty())
image_window.Hide();
}
示例6:
void
WaypointDetailsWidget::UpdatePage()
{
info_dock.SetVisible(page == 0);
details_panel.SetVisible(page == 1);
commands_dock.SetVisible(page == 2);
bool image_page = page >= 3;
if (!images.empty()) {
image_window.SetVisible(image_page);
magnify_button.SetVisible(image_page);
shrink_button.SetVisible(image_page);
}
}
示例7: LogStartUp
void
FlarmDetails::LoadSecondary()
{
LogStartUp(_T("OpenFLARMDetails"));
// if (FLARM Details already there) delete them;
if (!FLARM_Names.empty())
FLARM_Names.clear();
TLineReader *reader = OpenDataTextFile(_T("xcsoar-flarm.txt"));
if (reader != NULL) {
LoadSecondaryFile(*reader);
delete reader;
}
}
示例8: layout
void
WaypointDetailsWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
for (const auto &i : waypoint.files_embed) {
if (images.full())
break;
try {
if (!images.append().LoadFile(LocalPath(i.c_str())))
images.shrink(images.size() - 1);
} catch (const std::exception &e) {
LogFormat("Failed to load %s: %s",
(const char *)NarrowPathName(Path(i.c_str())),
e.what());
images.shrink(images.size() - 1);
}
}
const Layout layout(rc, waypoint);
WindowStyle dock_style;
dock_style.Hide();
dock_style.ControlParent();
WindowStyle button_style;
button_style.Hide();
button_style.TabStop();
if (allow_navigation)
goto_button.Create(parent, look.button, _("GoTo"), layout.goto_button,
button_style, *this, GOTO);
if (!images.empty()) {
magnify_button.Create(parent, layout.magnify_button, button_style,
new SymbolButtonRenderer(look.button, _T("+")),
*this, MAGNIFY);
shrink_button.Create(parent, layout.shrink_button, button_style,
new SymbolButtonRenderer(look.button, _T("-")),
*this, SHRINK);
}
if (allow_navigation) {
previous_button.Create(parent, layout.previous_button, button_style,
new SymbolButtonRenderer(look.button, _T("<")),
*this, PREVIOUS);
next_button.Create(parent, layout.next_button, button_style,
new SymbolButtonRenderer(look.button, _T(">")),
*this, NEXT);
}
close_button.Create(parent, look.button, _("Close"), layout.close_button,
button_style, dialog, mrOK);
info_dock.Create(parent, layout.main, dock_style);
info_dock.SetWidget(&info_widget);
details_panel.Create(parent, look, layout.main, dock_style);
details_text.Create(details_panel, layout.details_text);
details_text.SetFont(look.text_font);
details_text.SetText(waypoint.details.c_str());
#ifdef HAVE_RUN_FILE
const unsigned num_files = std::distance(waypoint.files_external.begin(),
waypoint.files_external.end());
if (num_files > 0) {
file_list.Create(details_panel, layout.file_list,
WindowStyle(), layout.file_list_item_height);
file_list.SetItemRenderer(&file_list_handler);
file_list.SetCursorHandler(&file_list_handler);
file_list.SetLength(num_files);
}
#endif
commands_dock.Create(parent, layout.main, dock_style);
commands_dock.SetWidget(&commands_widget);
if (!images.empty())
image_window.Create(parent, layout.main, dock_style,
[this](Canvas &canvas, const PixelRect &rc){
OnImagePaint(canvas, rc);
});
last_page = 2 + images.size();
}
示例9:
/**
* Search for the last traffic in the ordered list.
*/
const FLARM_TRAFFIC *LastTraffic() const {
return traffic.empty() ? NULL : traffic.end() - 1;
}
示例10: size
PixelRect
ButtonPanel::BottomLayout(PixelRect rc)
{
assert(!buttons.empty());
const unsigned n_buttons = buttons.size();
const unsigned total_width = rc.GetWidth();
/* naive button distribution algorithm: distribute as many buttons
as possible into each row; weakness: the last row may have only
one button */
struct Row {
unsigned start, end;
constexpr unsigned size() const {
return end - start;
}
};
StaticArray<Row, 8u> rows;
for (unsigned i = 0; i < n_buttons;) {
unsigned end = FitButtonRow(i, total_width);
assert(end > i);
auto &row = rows.append();
row.start = i;
row.end = i = end;
}
assert(!rows.empty());
/* optimise the naive result: try to move buttons down until we see
no further chance for improvement */
bool modified;
do {
modified = false;
for (unsigned i = rows.size() - 1; i > 0; --i) {
auto &dest_row = rows[i];
auto &src_row = rows[i - 1];
/* the upper row has many more buttons than the lower row */
if (dest_row.size() + 2 <= src_row.size()) {
unsigned max_width = RangeMaxWidth(dest_row.start - 1, dest_row.end);
unsigned row_width = (dest_row.size() + 1) * max_width;
/* yes, we can move one button down */
if (row_width <= total_width) {
--src_row.end;
--dest_row.start;
modified = true;
}
}
}
} while (modified);
/* now do the actual layout based on row metadata */
for (int i = rows.size() - 1; i >= 0; --i) {
const auto &row = rows[i];
rc = HorizontalRange(rc, row.start, row.end);
}
return rc;
}
示例11: StartTile
void StartTile(unsigned index) {
if (!segments.empty() && !segments.back().IsTileSegment())
/* link current marker segment with this tile */
segments.back().tile = index;
}
示例12: GetCurrentIndex
unsigned GetCurrentIndex() const {
assert(!children.empty());
return current;
}
示例13: GetWidget
Widget &GetCurrentWidget() {
assert(!children.empty());
return GetWidget(current);
}
示例14: Average
/**
* Calculate average from samples
*
* @return Average value in buffer
*/
gcc_pure
fixed Average() const {
assert(!x.empty());
return std::accumulate(x.begin(), x.end(), fixed(0)) / x.size();
}
示例15: IsDetected
bool IsDetected() const {
return available || !traffic.empty();
}