Boost logo

Boost Users :

Subject: Re: [Boost-users] STL MAP Insertion and Updates ..!!
From: Lars Viklund (zao_at_[hidden])
Date: 2013-12-25 10:21:04


Dear illiterate repeat offender.

Please pick _ONE_ list to send your message to.

Please _TRY_ to make your letter on topic for that list.

The message below has _nothing_ to do with _ANY_ Boost list, nor Boost
at all, and you are soon going to give me a brain bleeding if you don't
stop doing this.

Just because someone gave you help out of pity or morbid curiousity in
the past doesn't mean you can keep being ignorant and ignoring of things
being told to you.

If you cannot grasp the very fundamental fundamentals of communication,
please consider not doing it at all.

STOP. IT.

Merry holidays and whatever,
Everyone (via an angry lad)

On Wed, Dec 25, 2013 at 08:26:20PM +0530, Rahul Mathur wrote:
> Hi,
>
> Looking for clue for below. Having a code which has to be inserted and
> updated with following status -
>
> 1. Insert with unique ID and initially with two values (viz . v1[1100] &
> v2[1000])
> 2. If v1 [viz 1100] is NOT accepted exit.
> 3. Else value v2[1000] is accepted. With v2 being accepted, further insert
> with same unique ID on which v2 was accepted but now either with three
> values of v3[1001] or v4[1002] or v5[1003] and UPDATE the STL MAP.
> 4. Print the FINAL value (v2 or v3 or v5) of STL MAP with given unique ID.
>
> Did wrote below lines which works until value v1 [1000] insertion -
> ---
> #include <iostream>
> #include <algorithm>
> #include <map>
> #include <iterator>
>
> using namespace std;
>
> struct TBag {
> int UnqID;
> short value_code;
> TBag():UnqID(1234),value_code(1000){}
> };
>
> TBag ms_var1;
>
> typedef std::map<int, short> map1;
>
> class Apple {
> map1 abc;
>
> public:
> void TypeInsert ( TBag *ms_var );
> };
>
> void Apple::TypeInsert ( TBag *ms_var )
> {
> // Insert the 'UnqID' with messages of either TC = 1000 or 1100 only.
> typedef std::pair <map1::iterator, bool> itr;
> itr it1 = abc.insert( std::make_pair( ms_var->UnqID,
> ms_var->value_code ) );
> typedef std::pair <map1::iterator, bool> itr;
>
> //Searching for value of Value Code = 1000
> if (ms_var->value_code == 1100) {
> std::cout << "Value Error." << endl;
> exit (1);
> }
> if (it1.second) { // Checking correct insertion happened with 1000
> std::cout << "Unq ID (" << it1.first->first << ") => " <<
> "Value Code (" << it1.first->second << ")" << endl;
> std::cout << "The Status is .." << it1.first->first << " &
> " << it1.first->second << endl ;
>
> // INSERT now with Value code of either 1001 or 1002 or 1003
> & finally UPDATE the STL MAP
>
> std::cout << "Final Status:" << endl ;
> for( map<int, short>::iterator iter = map1.begin(); iter !=
> map1.end(); ++iter )
> std::cout << iter->first << " " << iter->second <<
> endl ;
> std::cout << "All Status successful." << endl;
> }
> else
> std::cout << "Status Error." << endl;
> }
>
> int main () {
> Apple ms;
> ms.TypeInsert( &ms_var1 );
> return 0;
> }
> ---
>
> Any help is well appreciated ..:)
>
> ~ XoXo

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

-- 
Lars Viklund | zao_at_[hidden]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net