Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. ...
  2. #include <cctype>
  3. ...
  4. //------------------------------------------------------------------------------
  5. // Find a specific album by title
  6. //------------------------------------------------------------------------------
  7. int Jukebox::findAlbumIndex(std::string &pAlbumToSearch)
  8. {
  9.     auto it = find_if(vectorJukebox.begin(), vectorJukebox.end(), [&pAlbumToSearch](const Album &a)
  10.     {
  11.         std::string albumName = a.getAlbum();
  12.  
  13.         return ((albumName.size() == pAlbumToSearch.size()) && std::equal(albumName.begin(), albumName.end(), pAlbumToSearch.begin(), [](char& c1, char& c2) {
  14.             return (c1 == c2 || std::toupper(c1) == std::toupper(c2));
  15.         }));
  16.     });
  17.  
  18.  
  19.     int index = distance(vectorJukebox.begin(), it);
  20.  
  21.     return index;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement