|
From: Per W. <pw...@ia...> - 2006-05-20 21:29:41
|
You haven't shown the full code for your objects, but...
The inner loop seems to add multiple entries to the SEQ hash.
The outher loop removes a single entry from the SEQ hash.
That makes SEQ constantly growing, making SEQ.size constantly growing.
Note that for most container classes (STL or home-grown), it is
problematic to iterate through all elements while at the same time add or
remove entries.
/Per W
On Sat, 20 May 2006, Erik Schmidt wrote:
> for(int j=0;j<SEQ.size();j++){
>
> for(int k=0;k<codons.size();k++){
>
> SEQ.add(SEQ.get_keys()[j]+codons[k],1);
>
> }
>
> SEQ.remove(j);
>
> }
>
> above is the code I'm using.
>
> SEQ is an object of my own devising called "Hash"
>
> it functions exactly like an STL vector, except instead of having
> integer values call the data, it has a string key that calls data.
> for those of you who know perl, you know exactly what I'm trying to do.
>
> codons is a vector <string>
>
> can anyone give me any insight towards why the outer for loop is
> infinite?
>
> SEQ.remove(j) is like saying vector <string>::erase
|