本文整理汇总了C++中SongList::find方法的典型用法代码示例。如果您正苦于以下问题:C++ SongList::find方法的具体用法?C++ SongList::find怎么用?C++ SongList::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SongList
的用法示例。
在下文中一共展示了SongList::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadSongList
size_t LoadSongList( SongList &songs )
{
size_t count = 0;
FILE *fp = fopen( "musicdb.txt", "rt" );
if (!fp) return 0;
string artist;
string fullpath;
string title;
char line[6144], *ch;
while (!feof(fp))
{
fgets( line, 6144, fp );
cleanString( line );
ch = strtok( line, "\t" );
if (ch) artist = ch;
else continue;
ch = strtok( NULL, "\t" );
if (ch) title = ch;
else continue;
ch = strtok( NULL, "\t" );
if (ch) fullpath = ch;
else continue;
printf ("Artist: %s\nTitle: %s\nFullPath: %s\n",
artist.c_str(),
title.c_str(),
fullpath.c_str() + 60 );
count++;
SongList::iterator sli;
sli = songs.find( artist );
if (sli == songs.end())
{
songs[artist] = std::vector<Song>();
sli = songs.find( artist );
assert( sli != songs.end() );
}
Song s;
s.filename = fullpath;
s.title = title;
(*sli).second.push_back( s );
}
fclose(fp);
return count;
}
示例2: GetSongNamesForCurrentArtist
void GetSongNamesForCurrentArtist()
{
string aname = artistNames[currArtistNdx];
SongList::iterator ai = songs.find( aname );
if (ai == songs.end() )
{
printf("Could not find %s\n", aname.c_str() );
return;
}
std::vector<Song> &asongs = (*ai).second;
printf("GetSongNamesForCurrentArtist---\n" );
printf("%d songs... \n", asongs.size() );
songNames.clear();
songPath.clear();
for ( std::vector<Song>::iterator si = asongs.begin();
si != asongs.end(); ++si )
{
songNames.push_back( (*si).title );
songPath.push_back( (*si).filename );
}
}