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


C++ OrderList::size方法代码示例

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


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

示例1: getOrders

OrderList PgsqlDataProvider::getOrders(OrderType type, string methodName, uint32_t stockId)
{
  OrderList orderList;

  nontransaction command(*conn);  
  string query = "SELECT id, broker_id, stock_id, amount, price FROM " + methodName + "(" + to_string(stockId) + ");";
  result queryResult(command.exec(query));
  
  if (verbose)
    cout << "Result of " << query << ": " << endl;

  ResultIterator endIterator = queryResult.end();
  for (ResultIterator iterator = queryResult.begin(); iterator != endIterator; ++iterator) 
  {
    Order order;
    order.setId(iterator[0].as<uint64_t>());
    order.setType(type); 
    order.setBrokerId(iterator[1].as<uint32_t>());
    order.setStockId(iterator[2].as<uint32_t>());
    order.setAmount(iterator[3].as<uint32_t>());
    order.setPrice(Decimal(iterator[4].as<string>()));
    orderList.push_back(order);
  }

  if (verbose)
    cout << orderList.size() << " orders. " << endl;

  return orderList;
}
开发者ID:junajan,项目名称:nodejs-stock,代码行数:29,代码来源:PgsqlDataProvider.cpp

示例2: matchOrders

void OrderMatcher::matchOrders(TradeList& tradeList, OrderList& buyList, OrderList& sellList, Decimal price)
{
  if (verbose)
    cout << endl << "Matching orders..." << endl;

  if (buyList.size() == 0 || sellList.size() == 0) 
    return;

  Order buyOrder = buyList.front();
  Order sellOrder = sellList.front();

  bool finished = false;

  while (!finished && buyOrder.getPrice() >= price && sellOrder.getPrice() <= price)
  {
    uint32_t amount = std::min(buyOrder.getAmount(), sellOrder.getAmount());

    Trade trade(amount, price, buyOrder, sellOrder);
    tradeList.push_back(trade);
    buyOrder.decreaseAmount(amount);
    sellOrder.decreaseAmount(amount);

    if (buyOrder.getAmount() == 0)
    {
      buyList.pop_front();
      if (buyList.size() > 0) 
	buyOrder = buyList.front();
      else
	finished = true;
    }

    if (sellOrder.getAmount() == 0)
    {
      sellList.pop_front();
      if (sellList.size() > 0) 
	sellOrder = sellList.front();
      else
	finished = true;
    }
  }
}
开发者ID:junajan,项目名称:nodejs-stock,代码行数:41,代码来源:OrderMatcher.cpp

示例3: matchesAt

UBool OrderList::matchesAt(int32_t offset, const OrderList &other) const
{
    // NOTE: sizes include the NULLORDER, which we don't want to compare.
    int32_t otherSize = other.size() - 1;

    if (listSize - 1 - offset < otherSize) {
        return FALSE;
    }

    for (int32_t i = offset, j = 0; j < otherSize; i += 1, j += 1) {
        if (getOrder(i) != other.getOrder(j)) {
            return FALSE;
        }
    }

    return TRUE;
}
开发者ID:Distrotech,项目名称:icu,代码行数:17,代码来源:ssearch.cpp


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