brandon-a / CIS-22C-Group-Project

Using different data structures to organize USDA nutritional facts.
0 stars 0 forks source link

Searching secondary BST #26

Closed brandon-a closed 8 years ago

brandon-a commented 8 years ago

Use the following to search without an exact match.

name.substr(0,search.length());
brandon-a commented 8 years ago

Not sure what you meant by this @theorangepotato. I tried using it and it doesn't seem to do what I thought it would. Did I misunderstand?

theorangepotato commented 8 years ago

So, instead of saying:

if(target.getName() == nodePtr->getItem()->getName())
     ...

Which would look for an exact match, use:

if(target.getName() == nodePtr->getItem()->getName().substr(0, target.getName().length()))
     ...

Which sees if the search string matches the beginning of the description.

Also, while I'm looking at that member function, there should not be an else if immediately after the above code because that will only match one result.

brandon-a commented 8 years ago

I added the changes and it works, but in order to have multiple items appear I would have to rewrite a bunch and so would Ahmed in the search manager. Do we need to be able to find multiple. If so I can make the changes and maybe Ahmed can help as well otherwise I can make changes in Seachmanager.cpp.

theorangepotato commented 8 years ago

1) On the current commit, I got a core dump when I searched for 'cheese' in the small data set. It did not give any results before it did.

2) I think the secondary key does need to be able to give multiple results. Sorry :disappointed:

brandon-a commented 8 years ago

I updated the search function to give one result and will not crash when searching for cheese anymore. I will commit in a few minutes.