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


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

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


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

示例1: match

ZR::RetVal MyOrders::match( Order * myOrder )
{
    if( myOrder->m_locked ) return ZR::ZR_FINISH;

    OrderList asks;
    m_asks->filterOrders( asks, myOrder->m_currency );
    ZR::ZR_Number amount = myOrder->m_amount;
    for( OrderIterator askIt = asks.begin(); askIt != asks.end(); askIt++ ) {
        Order * other = *askIt;
        if( other->m_ignored ) continue;   // trying to execute this order did not go well in the past. Don't try again.
        if( other->m_isMyOrder ) continue; // don't fill own orders
        if( myOrder->m_matched.find( other->m_order_id ) != myOrder->m_matched.end() ) continue; // matched that already
        if( myOrder->m_price < other->m_price ) break;    // no need to try and find matches beyond
        std::cerr << "Zero Reserve: Match at ask price " << other->m_price.toStdString() << std::endl;

        myOrder->m_matched.insert( other->m_order_id );

        if( amount > other->m_amount ) {
            buy( other, myOrder, other->m_amount );
        }
        else {
            buy( other, myOrder, amount );
            return ZR::ZR_FINISH;
        }
        amount -= other->m_amount;
    }
    return ZR::ZR_SUCCESS;
}
开发者ID:RetroShare,项目名称:ZeroReserve,代码行数:28,代码来源:MyOrders.cpp

示例2: init

ZR::RetVal MyOrders::init()
{
    try {
        OrderList myorders;
        ZrDB::Instance()->loadOrders( &myorders );
        for( OrderIterator it = myorders.begin(); it != myorders.end(); it++) {
            Order * order = *it;
            addOrder( order );
            if( order->m_orderType == Order::ASK ) {
                m_asks->addOrder( order );
            }
            else {
                m_bids->addOrder( order );
            }
        }
    }
    catch( std::runtime_error & e ) {
        g_ZeroReservePlugin->placeMsg( std::string( "Exception caught: " ) + e.what() );
        return ZR::ZR_FAILURE;
    }
    return ZR::ZR_SUCCESS;
}
开发者ID:RetroShare,项目名称:ZeroReserve,代码行数:22,代码来源:MyOrders.cpp


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