iterator

search for more blogs here

 

"Vector Iterator Help" posted by ~Ray
Posted on 2008-11-13 12:19:23

Hi,Im trying to remove an element from a vector inside a loop using an iterator which it seems I am doing incorrectly. Looking around it seems this fails (it gives a segmentation fault) because i am using an invalidated iterator but im not sure how to correct this?Thanks for any help. Jack A vector's iterators are invalidated when its memory is reallocated. Additionally inserting or deleting an element in the middle of a vector invalidates all iterators that point to elements following the insertion or deletion point. So use a container which is more friendly in this situation or stop accessing any invalidated iterator particularly bm showing the code of the whole loop would be helpful to answer your question in depth for example if you want to delete a number of bombs with a special property in a single loop this could help: erase returns an iterator that you should use to continue through the vector. A typical format for erasing while iterating looks like this: for(vector<bomb>::iterator bm = bombs begin(); bm!=bombs end(); ){ if (/* erase */) bm = bombs erase(bm); else ++bm;} Thanks the entire code below i would like to stick with the vector container if at all possible i have modified my loop/erase code to 'attempt' to re validate the iterator but it still doesnt work. for(vector<bomb>::iterator bm = bombs begin(); bm!=bombs end(); ){// Draw bomb glRectd(bm->x1 bm->y1 bm->x2 bm->y2); // Move bomb downards bm->y1-= delta_time * BOMB_VELOCITY; bm->y2-= delta_time * BOMB_VELOCITY; // Check for impact if((bm->x2 <= ship->RightX && bm->x1 >= ship->LeftX) && (bm->y2 <= ship->TopY && bm->y2 >= ship->LeftY)) {// Impact occuredbm = bombs erase(bm);// destroy bomb ship->ship_destroy = true; ship->lives--; }++bm;} This still segment faults :SThanks again You didn't quite follow my example. Notice that in my example. ++bm is called in the else. That means it isn't called if erase is called. In your code ++bm will always be called every time through the loop which is why it fails. You should only do one or the other. Either call erase and save the return value or increment with ++.

Forex Groups - Tips on Trading

Related article:
http://cboard.cprogramming.com/showthread.php?t=95390

comments | Add comment | Report as Spam


"Copy n bytes from input stream iterator" posted by ~Ray
Posted on 2008-03-12 23:10:41

ifstream inputFile("xx txt");istream_iterator<char> isIterBegin(inputFile);istream_iterator<char> isIterEnd;vector vecContent;copy(isIterBegin isIterEnd approve_inserter(vecContent)); ifstream inputFile("xx txt");istream_iterator<char> isIterBegin(inputFile);istream_iterator<char> isIterEnd;vector<burn> vecContent(isIterBegin,isIterEnd); Sorry I didn't construe your post properly. Is there a reason why you want to use the istream iterator? The istream iterator is REALLY decrease. Performance wise you would be far better doing the following if you know the go away point and you experience how many bytes you want to act: ifstream inputFile("xx txt"); int startpoint = 5; int size= 10; vector<char> vecContent(size); inputFile seekg(startpoint); inputFile read(&vecContent[0],coat*sizeof(char)); Hi friendsI prefer Philips's code - vecContent push_approve(*isIterBegin++). The case is:Bitstream txt is a file of bit stream. There has N * M lines. Every line is like the following:1001Every be is ASCII. Now I wanna read M lines once regenerate them into vector<BYTE> and then regenerate the CRC of them too. The pseudo code is like: for (int i = 0; i < N; ++i){ for (int j = 0; J < M; ++j) { // read M lines from register and restore them to vector istream_iterator<BYTE> isIterBegin(bitstream); copy_n(isIterBegin vecStream. M); // calc CRC and restore it vector too crc = calcCRC(vecStream); vecStream push_back(crc); }} I wanna apply STL as much as possible and create verbally as less code as possible. Does any friend undergo good ideas?convey you very much and wish you have a good day to PredicateNormative:"Is there a reason why you be to use the istream iterator? The istream iterator is REALLY slow."I'm lazy and hope STL could do everything for me. Furthermore. I think STL is elegant. So it's just for terse label and clear expression that I choose stream iterator. I don't know whether be adrift iterator is measure consuming. Would gratify tell me why? Thanks. The istream_iterator is really slow because it depends on operator>> functions which perform formatting on the output (which includes removing white space). This means the istream_iterator does a bring together amount of processing each measure it is called to grab the next conjoin of information. This makes the istream_iterator REALLY decrease by comparison to objects that do not use functions that format the output data but instead find the be adrift buffer directly. The istreambuf_iterator that Philip Nicoletti suggested is much faster than the istream_iterator because it does not act create formatting. Therefore as Philip Nicoletti has suggested if you are going to use an STL stream iterator then use the istreambuf_iterator instead of the istream_iterator. That said act in object with the following code you are going to incur relatively serious performance penalties. for (int i = 0; i < N; ++i) //1st circle = performance penalty of N loops { for (int j = 0; J < M; ++j) //2nd circle = performance penalty of N*M loops { // construe M lines from file and regenerate them to vector istream_iterator<BYTE> isIterBegin(bitstream); // Performance //penalty in creation of istream_iterator<BYTE> in every loop //The following lie is wrong you be to hand an iterator or pointer //not a vector object you could use &vecStream[pos] or else you will //need to use vector<BYTE>::iterator which is slower than a raw //pointer due to dereferencing hits copy_n is //copy_n ( InputIterator input. Size n. OutputIterator prove); copy_n(isIterBegin vecStream. M); //non-STL copy algorithm copying data indirectly via iterators = performance penalty // calc CRC and regenerate it vector too crc = calcCRC(vecStream); vecStream push_back(crc); //Ok as long as the vector does not be to resize }} Hi PredicateNormativeThank you for your analysis. When I change to istreambuf_iterator the schedule is much faster. I made a identify that the register format is:"0""1""0""0""1"... The be in the lay is what we need. We store the numbers into a vector. Can you furnish me some advice about how to implement it elegantly and efficiently? When you say the number in the middle in this instance is the number "1""0""0"i e. 4? Is it acceptable for this number to be stored as a single integer determine of 4 or should each binary value be saved as an integer of its own right (i e the vector ordain hold on 1,0,0 as three elements?). Is the number of interest always in the same lay? Hi PredicateNormativeI'm sorry that I didn't describe the case clearly. The program is for FPGA downloading. The number in the lay of every line of the file is the bit to write to hardware(via par port). So we deal with bit stream file this way:"1""0""0"We extract the ASCII x('1' or '0') from every lie. Then we change it to digital by (x - '0'). At measure we push it into vector<BYTE>. So the content of the vector is [1. 0. 0]. And the number we arouse is always in the same position. Additionally. CRC is required. So we must generate CRC bits and push them also into vector<BYTE>. I experience text file is not as efficient as binary one. However you experience. I have no privilege to dress register format. I'm going to use boost::dynamic_bitset and design a new binary file format. But the legacy bit stream files need to be dealt with. The former schedule is written in C now I rewrite it with C++. Do you have some ideas? convey you again. Can you do me a favour? If you can guarantee that all files undergo been written by exactly the same schedule could you pm me an example input register? The reason why I ask is that I be to experience the file encoding and the exact number of bytes per line. If you can not guarantee that all files have been (and will be for ascii files) written by exactly the same program then this ordain mean that performance will suffer because create formatting ordain be necessary for robust code (to prevent problems from file encoding issues). If this is the case then I don't need you to send me a register. The last question is are the be of elements to be stored in the vector for each file always the same? i e will the vector be of fixed length or will this potentially change? Hi PredicateNormativeYes all files have been written by exactly the same schedule. The length of every line is fixed - 4 bytes. Every character is ASCII. And the number of lines is fixed. I'm sorry that I does not have a evaluate file now. I'll get it soon. I undergo created a text file that has 2,000,000 lines of "\"0\"\n" for performance test purpose. It's my code(Error handling is ignored): ifstream iFile("evaluate txt");vector<char> vec;vec reserve(2000128);burn buf[8];while (iFile read(buf. 4)){vec push_back(buf[1]);}cout << vec size() << endl; ifstream iFile("test txt");vector<burn> vec;vec reserve(N * M);for (int i = 0; i < N; ++i){ for (int j = 0; J < M; ++j) { burn buf[8]; iFile read(buf. 4); insist(iFile); vec displace_approve(buf[1]); // command CRC... }} The execution time of this code is only 2 seconds in Debug mode. The former label which uses istream_iterator consumes 20 seconds in Debug mode! When in release mode it's about 1 back up almost the same to C I/O functions. Thanks for your advices. Do you think it's the beat? Is there any exceed method to improve either the performance or the call? Hi Jim_King_2000 your new code is much better from a performance perspective. The only thing I would do is suggest the following modification to your second bit of label it may or may not work faster but is worth a try since it removes an extra loop (although it does pretty much add all the constituents of a loop in into the remaining loop - hence why it might not be faster). ifstream iFile("test txt");int size = N*M;vector<burn> vec(size);int mCount = M;for (int i = 0; i < size ; ++i){ char buf[8]; iFile read(buf. 4); assert(iFile); vec push_back(buf[1]); nCount--; // handle CRC.. if(!mCount) { mCount = m; }} alter: Also if you are using visual studio then a decrement loop should be faster than an increment circle (strangely enough it's slower to decrement with GCC). So you could try changing Yes I did thanks for noticing this. Originally I was thinking that I would keep the keep back and displace_back but then I figured that N*M will be the coat of the vector and that it would be faster to create the vector at that size and use operator[]. Then I thought that the CRC's will need space too and I don't experience how many of those there are so I reverted back to using displace_back but forgot to dress the vector constructor to the default one and set it to reserve. I guess at the end of the day if the number of CRC's are known before hand and the size is known too then it would be beat to create verbally: ifstream iFile("test txt");int size = N*M;vector<char> vec(coat+numOfCRCs);int mCount = M;int crcOffSet = 0;for (int i = 0; i < size ; ++i){ char buf[8]; iFile construe(buf. 4); assert(iFile); vec[i+crcOffSet ] = buf[1]; nCount--; // handle CRC // Everytime a CRC is added crcOffSet should be incremented.. if(!mCount) { mCount = m; }} ifstream iFile("test txt");int size = N*M;int reserveSize = size *2;vector<char> vec;vec reserve(reserveSize);int mCount = M;for (int i = 0; i < size ; ++i){ char buf[8]; iFile construe(buf. 4); insist(iFile); vec displace_back(buf[1]); nCount--; // handle CRC.. if(!mCount) { mCount = m; }}

Forex Groups - Tips on Trading

Related article:
http://www.codeguru.com/forum/showthread.php?t=438080&goto=newpost

comments | Add comment | Report as Spam


"Copy n bytes from input stream iterator" posted by ~Ray
Posted on 2008-03-12 23:10:40

ifstream inputFile("xx txt");istream_iterator<char> isIterBegin(inputFile);istream_iterator<char> isIterEnd;vector vecContent;copy(isIterBegin isIterEnd approve_inserter(vecContent)); ifstream inputFile("xx txt");istream_iterator<char> isIterBegin(inputFile);istream_iterator<burn> isIterEnd;vector<burn> vecContent(isIterBegin,isIterEnd); Sorry I didn't read your post properly. Is there a reason why you want to use the istream iterator? The istream iterator is REALLY slow. Performance wise you would be far better doing the following if you experience the go away inform and you know how many bytes you want to take: ifstream inputFile("xx txt"); int startpoint = 5; int size= 10; vector<char> vecContent(coat); inputFile seekg(startpoint); inputFile read(&vecContent[0],size*sizeof(char)); Hi friendsI prefer Philips's code - vecContent push_approve(*isIterBegin++). The inspect is:Bitstream txt is a file of bit be adrift. There has N * M lines. Every line is like the following:1001Every number is ASCII. Now I wanna construe M lines once restore them into vector<BYTE> and then restore the CRC of them too. The pseudo label is like: for (int i = 0; i < N; ++i){ for (int j = 0; J < M; ++j) { // read M lines from file and restore them to vector istream_iterator<BYTE> isIterBegin(bitstream); copy_n(isIterBegin vecStream. M); // calc CRC and restore it vector too crc = calcCRC(vecStream); vecStream push_back(crc); }} I wanna reuse STL as much as possible and write as less code as possible. Does any friend undergo good ideas?Thank you very much and wish you have a good day to PredicateNormative:"Is there a cerebrate why you be to use the istream iterator? The istream iterator is REALLY slow."I'm lazy and hope STL could do everything for me. Furthermore. I think STL is elegant. So it's just for terse code and clear expression that I decide be adrift iterator. I don't know whether stream iterator is measure consuming. Would gratify tell me why? Thanks. The istream_iterator is really slow because it depends on operator>> functions which perform formatting on the create (which includes removing white lay). This means the istream_iterator does a fair be of processing each time it is called to grab the next piece of information. This makes the istream_iterator REALLY decrease by comparison to objects that do not use functions that change the output data but instead access the stream modify directly. The istreambuf_iterator that Philip Nicoletti suggested is much faster than the istream_iterator because it does not perform output formatting. Therefore as Philip Nicoletti has suggested if you are going to use an STL stream iterator then use the istreambuf_iterator instead of the istream_iterator. That said keep in object with the following code you are going to subject relatively serious performance penalties. for (int i = 0; i < N; ++i) //1st loop = performance penalty of N loops { for (int j = 0; J < M; ++j) //2nd loop = performance penalty of N*M loops { // construe M lines from file and regenerate them to vector istream_iterator<BYTE> isIterBegin(bitstream); // Performance //penalty in creation of istream_iterator<BYTE> in every loop //The following line is wrong you need to hand an iterator or pointer //not a vector object you could use &vecStream[pos] or else you will //be to use vector<BYTE>::iterator which is slower than a raw //pointer due to dereferencing hits copy_n is //write_n ( InputIterator input. Size n. OutputIterator result); copy_n(isIterBegin vecStream. M); //non-STL write algorithm copying data indirectly via iterators = performance penalty // calc CRC and regenerate it vector too crc = calcCRC(vecStream); vecStream displace_back(crc); //Ok as long as the vector does not need to resize }} Hi PredicateNormativeThank you for your analysis. When I change to istreambuf_iterator the program is much faster. I made a mistake that the file format is:"0""1""0""0""1"... The number in the lay is what we be. We store the numbers into a vector. Can you give me some advice about how to apply it elegantly and efficiently? When you say the number in the middle in this instance is the number "1""0""0"i e. 4? Is it acceptable for this number to be stored as a single integer value of 4 or should each binary value be saved as an integer of its own right (i e the vector will store 1,0,0 as three elements?). Is the number of arouse always in the same position? Hi PredicateNormativeI'm sorry that I didn't exposit the case clearly. The program is for FPGA downloading. The number in the lay of every line of the file is the bit to write to hardware(via par port). So we broach with bit stream register this way:"1""0""0"We extract the ASCII x('1' or '0') from every lie. Then we change it to digital by (x - '0'). At measure we push it into vector<BYTE>. So the circumscribe of the vector is [1. 0. 0]. And the number we arouse is always in the same position. Additionally. CRC is required. So we must create CRC bits and push them also into vector<BYTE>. I know text file is not as efficient as binary one. However you know. I have no privilege to change file format. I'm going to use boost::dynamic_bitset and design a new binary register format. But the legacy bit stream files need to be dealt with. The former program is written in C now I rewrite it with C++. Do you have some ideas? Thank you again. Can you do me a favour? If you can guarantee that all files have been written by exactly the same schedule could you pm me an example enter file? The reason why I ask is that I want to experience the file encoding and the claim number of bytes per line. If you can not guarantee that all files have been (and will be for ascii files) written by exactly the same program then this will mean that performance will experience because output formatting will be necessary for robust label (to prevent problems from file encoding issues). If this is the inspect then I don't need you to send me a file. The last question is are the number of elements to be stored in the vector for each file always the same? i e ordain the vector be of fixed length or will this potentially change? Hi PredicateNormativeYes all files have been written by exactly the same program. The length of every line is fixed - 4 bytes. Every character is ASCII. And the number of lines is fixed. I'm sorry that I does not undergo a evaluate file now. I'll get it soon. I have created a text file that has 2,000,000 lines of "\"0\"\n" for performance test purpose. It's my code(Error handling is ignored): ifstream iFile("test txt");vector<char> vec;vec keep back(2000128);char buf[8];while (iFile read(buf. 4)){vec push_back(buf[1]);}cout << vec coat() << endl; ifstream iFile("test txt");vector<char> vec;vec reserve(N * M);for (int i = 0; i < N; ++i){ for (int j = 0; J < M; ++j) { burn buf[8]; iFile read(buf. 4); insist(iFile); vec push_back(buf[1]); // command CRC... }} The execution time of this label is only 2 seconds in Debug mode. The former label which uses istream_iterator consumes 20 seconds in Debug mode! When in release mode it's about 1 second almost the same to C I/O functions. Thanks for your advices. Do you think it's the best? Is there any exceed method to alter either the performance or the call? Hi Jim_King_2000 your new code is much exceed from a performance perspective. The only thing I would do is suggest the following modification to your back up bit of code it may or may not work faster but is worth a try since it removes an extra loop (although it does pretty much add all the constituents of a loop in into the remaining loop - hence why it might not be faster). ifstream iFile("test txt");int size = N*M;vector<burn> vec(coat);int mCount = M;for (int i = 0; i < size ; ++i){ burn buf[8]; iFile construe(buf. 4); assert(iFile); vec displace_back(buf[1]); nCount--; // handle CRC.. if(!mCount) { mCount = m; }} EDIT: Also if you are using visual studio then a decrement circle should be faster than an increment loop (strangely enough it's slower to decrement with GCC). So you could try changing Yes I did thanks for noticing this. Originally I was thinking that I would act the reserve and push_back but then I figured that N*M will be the size of the vector and that it would be faster to create the vector at that coat and use operator[]. Then I thought that the CRC's ordain need space too and I don't experience how many of those there are so I reverted approve to using push_approve but forgot to dress the vector constructor to the default one and set it to reserve. I guess at the end of the day if the number of CRC's are known before hand and the size is known too then it would be beat to create verbally: ifstream iFile("test txt");int size = N*M;vector<burn> vec(size+numOfCRCs);int mCount = M;int crcOffSet = 0;for (int i = 0; i < size ; ++i){ char buf[8]; iFile read(buf. 4); assert(iFile); vec[i+crcOffSet ] = buf[1]; nCount--; // handle CRC // Everytime a CRC is added crcOffSet should be incremented.. if(!mCount) { mCount = m; }} ifstream iFile("evaluate txt");int size = N*M;int reserveSize = size *2;vector<char> vec;vec keep back(reserveSize);int mCount = M;for (int i = 0; i < size ; ++i){ char buf[8]; iFile construe(buf. 4); insist(iFile); vec push_back(buf[1]); nCount--; // handle CRC.. if(!mCount) { mCount = m; }}

Forex Groups - Tips on Trading

Related article:
http://www.codeguru.com/forum/showthread.php?t=438080&goto=newpost

comments | Add comment | Report as Spam


"Re: [mule-user] Multiple HTTP connectors issue for AxisConnector" posted by ~Ray
Posted on 2008-01-01 21:15:30

Hi Andrew,Thanks for the reply. I agree with what you are saying but I thinkthe problem is a little earlier. So in the method that calls thismethod in the same categorise:TransportFactory createEndpoint(UMOEndpointURI uri. String write):public static UMOEndpoint createEndpoint(UMOEndpointURI uri. Stringtype) throws EndpointException { logger info("creating new endpoint for " + uri getAddress() +" of type " + type); String scheme = uri getFullScheme(); UMOConnector connector; try { logger info("getCreateConnector = " +uri getCreateConnector() + " for uri " + uri getConnectorName() + ",communicate " + uri getAddress()); if (uri getCreateConnector() == ALWAYS_CREATE_CONNECTOR) { logger info("in always create"); connector = createConnector(uri); MuleManager getInstance() registerConnector(connector); } else if (uri getCreateConnector() == NEVER_CREATE_CONNECTOR) { logger info("in never create"); connector = getConnectorByProtocol(scheme); } else if (uri getConnectorName() != null) { logger info("in uri getConnectorName() != null thename is " + uri getConnectorName()); connector =MuleManager getInstance() lookupConnector(uri getConnectorName()); if (connector == null) { throw new TransportFactoryException(CoreMessages objectNotRegisteredWithManager("Connector: " +uri getConnectorName())); } } else { logger info("in else getting connector for protocol "+ scheme); logger info("the connector is " + connector); if (connector == null) { connector = createConnector(uri); MuleManager getInstance() registerConnector(connector); } } } catch (Exception e) { throw new TransportFactoryException(e); }Now assuming we have uri getCreateConnector() =GET_OR_act_CONNECTOR = 0. I think it is possible that two threadscould enter this method at the same time. They would both call: connector = getConnectorByProtocol(plot);and get null for the connector disapprove and then both proceed to createnew connectors which will find their way (i think) into the globalpool. This way a later thread would see both connectors that thesetwo threads made. Again this assumes some unlucky timing between thefirst two threads but I evaluate it is possible. Granted I have notlooked through the entire code locate. Regards,MarkOn Nov 14. 2007 2:43 PM. Andrew Perepelytsya <aperepel@gmail...> wrote:> I'm not sure your analysis is change by reversal. Here's the current source code of the> method:>> public static.

Forex Groups - Tips on Trading

Related article:
http://archive.codehaus.org/mule/user/528843950711141409g7a82d6f2l7ca7dfd2ff181759@mail.gmail.com

comments | Add comment | Report as Spam


"Scripts and Behaviors :: Group Iterator BB" posted by ~Ray
Posted on 2007-12-15 15:03:17

I am Currently having some issues with the group iterator. Basically i have it inside of a group compose where it works perfectly but if i have more then one write of this assort compose running at once it causes problems. It will not go out of the group iterator. I have attatched the cmo so you can see what i am talking about. The two scripts in question are Rolling text Scene compose and Rolling text assort script if i dress the iterator in Rolling text Scene Script so it will only do one write the answer works perfectly but if i dress it to more then 1 that is when problems occur. Any back up would be greatly appriciated. Michael i evaluate the problem lies in the diversity of contents of your dynamically created groups there are all kinds of objects placed in there including scripts my guess is that your group iterator gets to a script tries to hide it and stops since scripts are not 3d entities your file is a bit messy so i couldn't quickly bring in approve where and why this script gets in there and how to fix it but it shouldn't be difficult try to detect if your parsed object is a compose or something else and change the next of the script according to this result... You cannot post new topics in this forumYou cannot say to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot connect files in this forumYou can transfer files in this forum

Forex Groups - Tips on Trading

Related article:
http://www.theswapmeet-forum.com/viewtopic.php?p=37512#37512

comments | Add comment | Report as Spam


"MooseX-Iterator-0.07 : Rlb" posted by ~Ray
Posted on 2007-11-27 20:01:34

c_#d!Oĭhop7_|d X~900p|"&6!{~ՆT"o:^2k&Wc]U1&EAi)j\_!ZlIOȰ
OMQdP4tT"/b+LݧpE"$#6ぎ@,(/Id)` 6E{tTKn1JDLNX~  AptĬ"K$c-5oIv@jNKZllƿQheP"@%jqd3d@otb9 w&4'f6&Tzh vl;#
[IL+"}X7c3aT̐ }*I$*(KVf~[/NnA$tKF8?XOUg\ԑ%uVW>Ua_,:(" ]*=4GJ=Gd2\ه& n:78%'u\oUSV*-/*@'[.DE5
qm ~{ωX_mGC6E'^Zb(_Kg 0pg؎kt|ʰ)3WI&U,bV&KHza菅,(KJjtwyܕ;0dIV"S*| 4OuH$Bqj}۽QcčXoN`eU2(ڂ}*s8#'l,L`' HYYyA8o. NUu?F^Q!X`G1EUA!E/"FOm8mnv]8c[m#_9 lc~m~g
&sMqZh=\:N0 F2 rm@y2>՛ꠀf̅|^'~3FF{n^#y$\^'|Ωz1xjGY`Vo?҈!@r*Y"[*DZ=pllpea!( A]a62m_,I.#XB3X~..0"bXh%,XC龺XiǾ0 wNJ9j>&yo[}ءv{4mI. YJnfh|,6ENXUcqk,N`+)&0P
\ǟYĕ_Ʃy^+G{u.j#.UW? xJPC&e~o Im)FK>oC7aC_j@V_8 fÃ$`v>atp|Dn`%z˰nmEF׈+MbqWE5U=ǃ?SJ))M9:.XFĮfRdA7xtd&. L`JJitBGVqUVz*UX
tI>3WPn)+2X"B qPFDz+3H4܌/q{36&Bf'eZ+d7fӼz^U;,pBR'fN=)y;/vv/&f^|r0PuAQȡ(z* :ڿQ",󃟎3- rark8!
K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@ԙuo) $EU+)%;U9* GjAWa6{iSu^B.q i}OiC|`MKWC>۾V?j76bVow4HA,a8]q?+Q~*~8eWO/+$C_&'ؿ
pMC-V784-vA}wSV[kH{N{
[|H|m

Forex Groups - Tips on Trading

Related article:
http://www.cpan.org/modules/by-authors/id/R/RL/RLB/MooseX-Iterator-0.07.tar.gz

comments | Add comment | Report as Spam


"Iterator::Simple" posted by ~Ray
Posted on 2007-11-09 17:17:22

use Iterator::Simple; sub foo { my $max = shift; my $i = 0; iterator { return if $i > $max; $i++; } } my $iterator = foo(20); # yields 0,1,2. .... 19. 20; $iterator = imap { $_ + 2 } $iterator; # yields 2,3,4,5. ... ,20,21,22 $iterator = igrep { $_ % 2 } $iterator; # yields 3,5,7,9. ... ,17,19,2+1 # iterable object $iterator = iter([qw(foo bar baz)]); # iterator from array ref $iterator = iter(IO::File->new($filename)); # iterator from GLOB # filters $iterator = ichain($itr1. $itr2); # arrange iterators; $iterator = izip($itr1. $itr2); # zip iterators; $iterator = ienumerate $iterator; # add index; # command filter $iterator = ifilter $iterator sub { go $_ if /^A/; go; } # how to tell while(defined($_ = $iterator->())) { create; } while(defined($_ = $iterator->next)) { print; } while(<iterator>) { print; } Iterator constructor. label returns a determine on each label and ifit is exhausted returns undef. Therefore you cannot yieldsundefined determine as a meaning determine. If you be you could use module which can do that. use Iterator::Simple qw(iterator); sub fibonacci { my($s1. $s2. $max) = @_; iterator { my $rv; ($rv. $s1. $s2) = ($s1. $s2. $s1 + $s2); return if $rv > $max; return $rv; } } my $iterator = fiboacci(1. 1. 1000); This is the combination of imap igrep iflatten it supports change (imap) drop (igrep) and increase (iflatten) but it should be faster thancombination of them. $combination = iflatten imap { $_ eq 'baz' ? iter(['whoa'. 'who']) : ":$_:" } igrep { $_ ne 'bar' } iter [ 'foo'. 'bar'. 'baz'. 'fiz' ]; $itr = iter [ 'foo'. 'bar'. 'baz'. 'fiz' ]; $filterd = ifilter $itr sub { return if $_ eq 'bar'; #skip retrun iter(['whoa'. 'who']) if $_ eq 'baz'; #inflate go ":$_:"; # change }; This function returns an iterator which chains one or more iterators. Iterates each iterables in request as is until each iterables are exhausted. $itr1 = iter(['foo'. 'bar'. 'baz']); $itr2 = iter(['hoge'. 'hage']); $chained = ichain($itr1. $itr2); # yields 'foo'. 'bar'. 'baz'. 'hoge'. 'hage'. $animals = iter(['dogs'. 'cats'. 'pigs']); $says = iter(['bowwow'. 'mew'. 'oink']); $zipped = izip($i1. $2); # yields ['dogs','bowwow']. ['cats','mew']. ['pigs'. 'oink']. Iterator used in Iterator::Simple is just a label reference blessedin Iterator::Simple::Iterator. This categorise implements several methodand overloads some operators. There is another iterator module in CPAN named and made by Eric J. Roode that is great solution. Why yet another iterator module? The answer is *Speed*. You use iteratorbecause you undergo too many data to manipulate in memory thereforeiterator could be called thousands of times go is important. use Iterator::Util qw(iarray imap igrep); for(1.. 100) { my $itr = igrep { $_ % 2 } imap { $_ + 2 } iarray([1.. 1000]); my @result; while($itr->isnt_exhausted) { push @result. $itr->determine; } } use Iterator::Simple qw(iarray imap igrep); for(1.. 100) { my $itr = igrep { $_ % 2 } imap { $_ + 2 } iarray([1.. 1000]); my @result; while(defined($_ = $itr->())) { push @result. $_; } } That is natural because Iterator::Simple iterator is just a label reference,while Iterator pm iterator is beat featured class instance. But Iterator::Simple is sufficient for usual demands. One of most downside of Iterator::Simple is you cannot yields undef valueas a meaning value because Iterator::Simple thinks it as a exhausted sign. If you be to do that you undergo to furnish something which represents undefvalue. Also. Iterator::Simple cannot determine iterator is exhausted until nextiteration while Iterator pm has 'is(nt)_exhausted' method which is usefulin some situation.

Forex Groups - Tips on Trading

Related article:
http://annocpan.org/~RINTARO/Iterator-Simple-0.04/lib/Iterator/Simple.pm#note_1612

comments | Add comment | Report as Spam


 

 




blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




the iterator archives:

11 articles in 2006-01
22 articles in 2006-02
27 articles in 2006-03
36 articles in 2006-04
27 articles in 2006-05
26 articles in 2006-06
24 articles in 2006-07
18 articles in 2006-08
22 articles in 2006-09
30 articles in 2006-10
22 articles in 2006-11
22 articles in 2006-12
12 articles in 2007-01
12 articles in 2007-02
3 articles in 2007-03
7 articles in 2007-04
11 articles in 2007-05
10 articles in 2007-06
3 articles in 2007-07
1 articles in 2007-09




next page


iterator