本文整理汇总了C++中StaticArray类的典型用法代码示例。如果您正苦于以下问题:C++ StaticArray类的具体用法?C++ StaticArray怎么用?C++ StaticArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StaticArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRandomType
static TaskPointFactoryType
GetRandomType(const LegalPointSet &l)
{
StaticArray<TaskPointFactoryType, LegalPointSet::N> types;
l.CopyTo(std::back_inserter(types));
return types[(rand() % types.size())];
}
示例2: CORRADE_COMPARE
void StaticArrayTest::convertPointer() {
StaticArray a;
int* b = a;
CORRADE_COMPARE(b, a.begin());
const StaticArray c;
const int* d = c;
CORRADE_COMPARE(d, c.begin());
/* Pointer arithmetic */
const StaticArray e;
const int* f = e + 2;
CORRADE_COMPARE(f, &e[2]);
/* Verify that we can't convert rvalues */
CORRADE_VERIFY((std::is_convertible<StaticArray&, int*>::value));
CORRADE_VERIFY((std::is_convertible<const StaticArray&, const int*>::value));
{
#ifdef CORRADE_GCC47_COMPATIBILITY
CORRADE_EXPECT_FAIL("Rvalue references for *this are not supported in GCC < 4.8.1.");
#endif
CORRADE_VERIFY(!(std::is_convertible<StaticArray, int*>::value));
CORRADE_VERIFY(!(std::is_convertible<StaticArray&&, int*>::value));
}
/* Deleting const&& overload and leaving only const& one will not, in fact,
disable conversion of const Array&& to pointer, but rather make the
conversion ambiguous, which is not what we want, as it breaks e.g.
rvalueArrayAccess() test. */
{
CORRADE_EXPECT_FAIL("I don't know how to properly disable conversion of const Array&& to pointer.");
CORRADE_VERIFY(!(std::is_convertible<const StaticArray, const int*>::value));
CORRADE_VERIFY(!(std::is_convertible<const StaticArray&&, const int*>::value));
}
}
示例3: convertStaticView
void StaticArrayTest::convertStaticView() {
StaticArray a;
const StaticArray ca;
const StaticArrayView b = a;
const ConstStaticArrayView cb = ca;
CORRADE_VERIFY(b.begin() == a.begin());
CORRADE_VERIFY(cb.begin() == ca.begin());
}
示例4: main
int main()
{
// print my name and this assignment's title
cout << "Lab 3b, The \"Write A Static Array Class Template\" Program \n";
cout << "Programmer: Licong Wang\n";
cout << "Editor(s) used: Visual studio 2013\n";
cout << "Compiler(s) used: Microsoft c++ complier\n";
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
StaticArray<int, 100> a;
string buf;
int key;
int value;
while (true)
{
cout << "Input an index and a value [Q to quit]: ";
cin >> buf;
if (buf == "Q" || buf == "q")
break;
key = atoi(buf.c_str());
cin >> buf;
value = atoi(buf.c_str());
a[key] = value;
}
cout << "\nI stored this many values : " << a.size() << endl;
cout << "These values are:" << endl;
vector<int> keys = a.keys();
for (int i = 0; i < keys.size(); i++)
cout << keys[i] << " " << a[keys[i]] << endl;
while (true)
{
cout << "Input an index for me to look up [Q to quit]: ";
cin >> buf;
if (buf == "Q" || buf == "q")
break;
else
{
key = atoi(buf.c_str());
if (a.containsKey(key))
cout << "Found it -- the value stored at " << key << " is " << a[key] << endl;
else
cout << "I didn't find it" << endl;
}
}
cout << "\nPress ENTER to continue.\n";
cin.ignore(); // prevent cin.get() from getting a new line from previous cin
cin.get();
}
示例5: assignArray
void assignArray(const StaticArray<T>& array) {
_size = 0;
if (_data) {
delete[] _data;
_data = 0;
}
initWithData(array.cArray(), array.size());
}
示例6: access
void StaticArrayTest::access() {
StaticArray a;
for(std::size_t i = 0; i != 5; ++i)
a[i] = i;
CORRADE_COMPARE(a.data(), static_cast<int*>(a));
CORRADE_COMPARE(*(a.begin()+2), 2);
CORRADE_COMPARE(a[4], 4);
CORRADE_COMPARE(a.end()-a.begin(), 5);
}
示例7: convertView
void StaticArrayTest::convertView() {
StaticArray a;
const StaticArray ca;
const ArrayView b = a;
const ConstArrayView cb = ca;
CORRADE_VERIFY(b.begin() == a.begin());
CORRADE_VERIFY(cb.begin() == ca.begin());
CORRADE_COMPARE(b.size(), 5);
CORRADE_COMPARE(cb.size(), 5);
}
示例8: readRegister
StaticArray<uint8_t,5> readRegister(Spi& pSpi, FiveByteRegister pRegister)
{
StaticArray<uint8_t,5> value;
uint8_t cmd = CMD_R_REGISTER | (pRegister & MASK_REGISTER_CMD);
pSpi.chipSelect(true);
pSpi.transfer(cmd);
for (size_t i = 0 ; i < value.size() ; ++i) {
value[i] = pSpi.transfer(CMD_NOP);
}
pSpi.chipSelect(false);
return value;
}
示例9: EndFan
virtual void
EndFan()
{
if (fans.full())
return;
// remove unnecessary inclusion of origin if next and last points are identical
unsigned start = 0;
const size_t gsize = g.size();
if (gsize > 2 && g[gsize - 1] == g[1])
start = 1;
if (gsize < start + 3)
return;
// Perform clipping on the GeoPointVector (Result: clipped)
unsigned size = clip.ClipPolygon(clipped, g.raw() + start, gsize - start);
// With less than three points we can't draw a polygon
if (size < 3)
return;
// Work directly on the RasterPoints in the fans vector
fans.Append(size);
// Convert GeoPoints to RasterPoints
for (unsigned i = 0; i < size; ++i)
fans.Append(proj.GeoToScreen(clipped[i]));
}
示例10: 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();
}
示例11: 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);
}
示例12: 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();
}
示例13: CalculateRoute
void CalculateRoute(const ProtectedRoutePlanner &route_planner) {
const ProtectedRoutePlanner::Lease lease(route_planner);
for (auto it = waypoints.begin(), end = waypoints.end(); it != end; ++it) {
VisibleWaypoint &vwp = *it;
const Waypoint &way_point = *vwp.waypoint;
if (way_point.IsLandable() || way_point.flags.watched)
vwp.CalculateReachability(lease, task_behaviour);
}
}
示例14: Visit
void Visit(const AirspaceWarning& as) {
if (as.GetWarningState() == AirspaceWarning::WARNING_INSIDE) {
ids_inside.checked_append(&as.GetAirspace());
} else if (as.GetWarningState() > AirspaceWarning::WARNING_CLEAR) {
ids_warning.checked_append(&as.GetAirspace());
locations.checked_append(as.GetSolution().location);
}
if (!as.IsAckExpired())
ids_acked.checked_append(&as.GetAirspace());
}
示例15: QuickMenuButtonRenderer
void
QuickMenu::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
WindowStyle grid_view_style;
grid_view_style.ControlParent();
grid_view_style.Hide();
const auto &dialog_look = UIGlobals::GetDialogLook();
const auto &font = *dialog_look.button.font;
const unsigned column_width = Layout::Scale(78u);
const unsigned row_height =
std::max(2 * (Layout::GetTextPadding() + font.GetHeight()),
Layout::GetMaximumControlHeight());
grid_view.Create(parent, dialog_look, rc, grid_view_style,
column_width, row_height);
SetWindow(&grid_view);
WindowStyle buttonStyle;
buttonStyle.TabStop();
for (unsigned i = 0; i < menu.MAX_ITEMS; ++i) {
if (buttons.full())
continue;
const auto &menuItem = menu[i];
if (!menuItem.IsDefined())
continue;
TCHAR buffer[100];
const auto expanded =
ButtonLabel::Expand(menuItem.label, buffer, ARRAY_SIZE(buffer));
if (!expanded.visible)
continue;
PixelRect button_rc;
button_rc.left = 0;
button_rc.top = 0;
button_rc.right = 80;
button_rc.bottom = 30;
auto *button = new Button(grid_view, button_rc, buttonStyle,
new QuickMenuButtonRenderer(dialog_look,
expanded.text),
*this, menuItem.event);
button->SetEnabled(expanded.enabled);
buttons.append(button);
grid_view.AddItem(*button);
}
grid_view.RefreshLayout();
UpdateCaption();
}