Skip to content

Commit

Permalink
Fix #42: iterator example udpate (TradingPool usage)
Browse files Browse the repository at this point in the history
  • Loading branch information
dingmaotu committed Jun 22, 2018
1 parent 0334e80 commit 649f098
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,12 @@ Here is a simple example:
// for simplicity, I will not use the Lang/Script class
void OnStart()
{
OrderList<Order*> list;
int total= TradingPool::total();
TradingPool pool;
LinkedList<Order*> list;
int total= pool.total();

This comment has been minimized.

Copy link
@yerden

yerden Jun 22, 2018

Contributor

BTW, total() method here is a bit confusing. It shows all orders from MODE_TRADES with no respect to its filter. Should, for example, count() method be added to count all orders satisfying pool's inner filter?

This comment has been minimized.

Copy link
@dingmaotu

dingmaotu Jun 22, 2018

Author Owner

@yerden Adding count() is a good idea. The total method is intended to be a wrapper for the OrdersTotal() function. Generally to iterate through an order pool, the foreachorder macro is recommended. I also noted that using Order::Select is wrong in this commit and TradingPool::select should be used.

Thanks for the suggestion.

for(int i=0; i<total; i++)
{
if(TradingPool::select(i))
if(Order::Select(i))
{
OrderPrint(); // to compare with Order.toString
list.push(new Order());
Expand Down

0 comments on commit 649f098

Please sign in to comment.