Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

stl - HowTo sort std::map? -


here map:

typedef std::map<int/*security id*/, positionmonth> portfoliomonth; 

where positionmonth structure, ex.:

struct positionmonth         {             nav::shares shares_;             nav::amount market_value_;              positionmonth(void)                 {}             positionmonth(const nav::amount& market_value                     , const nav::shares& shares)                 : market_value_(market_value)                 , shares_(shares)                 {}         }; 

question: how sort std::map second value key param (by market_value_, let int)? examples or links?

ps. boost methods not interested!

pps. i'm unable initialise std::map compare functor!

thanks help!


my solution (or how did myself):

template<class t>     struct lesssecondccy         : std::binary_function<t,t,bool>     {         inline bool operator ()(const t& _left, const t& _right)         {             return _left.second.market_value_.currency() < _right.second.market_value_.currency();         }     }; 

and in function:

typedef std::pair<int/*security id*/, _entry> data_t; 

where _entry positionmonth

std::vector<data_t> vec(item.funds_end_.begin(), item.funds_end_.end()); std::sort(vec.begin(), vec.end(), nav::lesssecondccy<data_t>()); 

done!

there several options gamedev.net. down thread posting fruny.

aside: why not consider boost possible solution provider? it's respected, peer evaluated, documented solution professional c++ coders.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -