Hey everyone,
So awhile back I built a program that contained a function to merge two databases (well SQLite ones that are read in as Lists). When the first database is read in, well the file, it's read into a Binary Search Tree, while the second is read into a List. The code will then go on to checking the BST for entries in the List. If a duplicate is found, the entry is removed from the List. Once that is all done, the BST is then converted to a sorted List, and merged with the second list that now contains no duplicated
Now I wanted to use a BST, because well I need to expand my knowledge for one, and I felt like it would make the comparison process a heck of a lot quicker.
Anyway here's where the error comes into play. Now I have run this program multiple times (well this part of the program) with no problems what so ever. However, today I went run it and everything looked good until I tried converting my BST back to a List. I get the following error "StackOverflowException was unhandled.
That's it. I have no clue what's causing it, and even more weird, this is the first time. After countless runs, I am now getting the error. Here's the code I use to convert the BST back to a List
public static void ConvertToList (BinaryTreeNode_ImageData node, ref List<ImageData> ImageData) //converts a BST to a List (sorted)
{
//this is recursively called, so we ref ImageData, that way it's the same item all the way back
if (node != null)
{
ConvertToList(node.Left, ref ImageData);
ImageData.Add(new ImageData());
ImageData [ImageData.Count - 1].ImageLink = node.Data.ImageLink;
ImageData [ImageData.Count - 1].Author = node.Data.Author;
ImageData [ImageData.Count - 1].Width = node.Data.Width;
ImageData [ImageData.Count - 1].Height = node.Data.Height;
ConvertToList(node.Right, ref ImageData);
}
}
So anyone got any ideas? Am I really maxing out this List? It's only about 23,009 entries long (I swear I have worked with lists that contain more, but then again I could be wrong). If you wonder all this does is hold strings and ints
Any help would be appreciated, thanks
Oh I should mention this is running on a BackgroundWorker, so I guess maybe a thread could be involved