I hope I'm doing this right since it's my first post.
I have a hash table (HList, vector) of lists and I want to use bubble sort to sort my list of entries (HashEntry,class). It compiles fine and temp is a valid list, but my temp.end() is a bad pointer.
void Hash::bubbles()
{
list<HashEntry> temp;
list<HashEntry>::iterator end, j, k;
for(int i = 0; i<HList.size();i++)
{
temp = HList[i];
//order the list
end = temp.end(); //HERE: bad ptr
for(int pass = 1; pass<temp.size(); pass++)
{//j before k
for(j = temp.begin(), k = temp.begin()++; j != end; j++, k++)
{
if((*j)>(*k))
std::iter_swap(j,k);
}
end--;
}
}
}
Please help. Thanks.