This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
PF3/hw1/Ex5/src/reentrantrwlock/MovieCatalog.java

67 lines
1.6 KiB
Java

package reentrantrwlock;
import java.util.Map;
import java.util.List;
import java.util.Random;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class MovieCatalog {
private final Map<String, Movie> movies;
private final ReentrantReadWriteLock rwlock;
private final Lock rLock, wLock;
private static final Random generator = new Random();
public MovieCatalog() {
movies = new TreeMap<>();
rwlock = new ReentrantReadWriteLock();
rLock = rwlock.readLock();
wLock = rwlock.writeLock();
}
/**
* Returns the current size of this catalog
* @return the size of this catalog
*/
public int getSize() {
// TODO: Implement method getSize
}
/**
* Returns a movie from this catalog
* @param the title of movie to be obtained
* @return the movie with the title provided or
* null if the movie is not in the catalog
*/
public Movie getMovie(String title) {
//TODO: Implement method getMovie
}
/**
* Returns the list of all movie titles in this catalog
* @return a list of the movie titles in this catalog
*/
public List<String> getTitles() {
//TODO: Implement method getTitles
}
/**
* Returns a random movie from this catalog
* @return a randomly selected movie from this catalog
*/
public Movie getRandomMovie() {
// TODO: Implement method getRandomMovie
}
/**
* Adds a movie to the catalog
* @param the movie to be added to the catalog
*/
public void addMovie(Movie movie) {
//TODO: Implement method addMovie
}
}