예제 #1
0
파일: User.cs 프로젝트: jmathon/Algo-2014-1
 public static void ReadRatings( User[] users, Movie[] movies, string path )
 {
     using( TextReader r = File.OpenText( path ) )
     {
         string line;
         while( (line = r.ReadLine()) != null )
         {
             string[] cells = line.Split( CellSeparator, StringSplitOptions.None );
             int idUser = int.Parse( cells[0] );
             int idMovie = int.Parse( cells[1] );
             if( idMovie >= 0 && idMovie < movies.Length
                 && idUser >= 0 && idUser < users.Length )
             {
                 users[idUser].Ratings.Add( movies[idMovie], int.Parse( cells[2] ) );
             }
         }
     }
 }
예제 #2
0
 public static void ReadMovies( string path, out Dictionary<int, Movie> first, out Dictionary<int, List<Movie>> duplicates )
 {
     first = new Dictionary<int, Movie>();
     duplicates = new Dictionary<int, List<Movie>>();
     using( TextReader r = File.OpenText( path ) )
     {
         string line;
         while( (line = r.ReadLine()) != null )
         {
             Movie exists, u = new Movie( line );
             if( first.TryGetValue( u.MovieID, out exists ) )
             {
                 List<Movie> list;
                 if( !duplicates.TryGetValue( u.MovieID, out list ) )
                 {
                     list = new List<Movie>();
                     duplicates.Add( u.MovieID, list );
                 }
                 list.Add( u );
             }
             else first.Add( u.MovieID, u );
         }
     }
 }