Skip to content

Instantly share code, notes, and snippets.

@vardanator
Created February 20, 2018 06:51
Show Gist options
  • Select an option

  • Save vardanator/1874c4bb23b526b3637e492201687215 to your computer and use it in GitHub Desktop.

Select an option

Save vardanator/1874c4bb23b526b3637e492201687215 to your computer and use it in GitHub Desktop.
// this is a pseudocode, that's why I didn't bother with "const&"'s and "std::"'s
// though it could have look better, forgive me C++ fellows
vector<Item*> GetItemsByKeywordInSortedOrder(string keyword)
{
// assuming IndexTable is a big hashtable mapping keywords to Item BSTs
BST<Item*> items = IndexTable[keyword];
// suppose BST has a function InOrderProduceVector(), which creates a vector and
// inserts into it items fetched via in-order traversing the tree
vector<Item*> sorted_result = items.InOrderProduceVector();
return sorted_result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment