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


C++ StaticArray类代码示例

本文整理汇总了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())];
}
开发者ID:j-konopka,项目名称:XCSoar-TE,代码行数:7,代码来源:harness_task.cpp

示例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));
    }
}
开发者ID:andylon,项目名称:corrade,代码行数:35,代码来源:StaticArrayTest.cpp

示例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());
}
开发者ID:andylon,项目名称:corrade,代码行数:9,代码来源:StaticArrayTest.cpp

示例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();
}
开发者ID:simida1234321,项目名称:TestOnly,代码行数:57,代码来源:MyStaticArray.cpp

示例5: assignArray

    void assignArray(const StaticArray<T>& array) {
      _size = 0;

      if (_data) {
        delete[] _data;
        _data = 0;
      }

      initWithData(array.cArray(), array.size());
    }
开发者ID:jeffreyhunter77,项目名称:cpp-objects,代码行数:10,代码来源:StaticArray.hpp

示例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);
}
开发者ID:andylon,项目名称:corrade,代码行数:10,代码来源:StaticArrayTest.cpp

示例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);
}
开发者ID:andylon,项目名称:corrade,代码行数:11,代码来源:StaticArrayTest.cpp

示例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;
}
开发者ID:abymmathew,项目名称:BtMqttSn,代码行数:14,代码来源:Bt_Rf24Device.cpp

示例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]));
  }
开发者ID:Adrien81,项目名称:XCSoar,代码行数:28,代码来源:MapWindowGlideRange.cpp

示例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();
  }
开发者ID:Advi42,项目名称:XCSoar,代码行数:31,代码来源:dlgWaypointDetails.cpp

示例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);
  }
开发者ID:Andy-1954,项目名称:XCSoar,代码行数:30,代码来源:dlgWaypointDetails.cpp

示例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();
  }
开发者ID:damianob,项目名称:xcsoar,代码行数:15,代码来源:AvFilter.hpp

示例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);
    }
  }
开发者ID:rjsikarwar,项目名称:XCSoar,代码行数:11,代码来源:WaypointRenderer.cpp

示例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());
  }
开发者ID:DRIZO,项目名称:xcsoar,代码行数:11,代码来源:AirspaceRenderer.cpp

示例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();
}
开发者ID:Exadios,项目名称:xcsoar-exp,代码行数:54,代码来源:dlgQuickMenu.cpp


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