treemaps for more treemaps

master
Caroline Hirwing 2 years ago
parent 6a821fa31d
commit ddf3ad0686
  1. 37
      ovning2/Searcher.java

@ -6,25 +6,25 @@ import java.util.Optional;
import java.util.SortedSet;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
public class Searcher {
private Map<String,Recording> umartist;
private Map<String,Recording> umtitel;
private Map<String,ArrayList<Recording>> umartist;
private Map<String,ArrayList<Recording>> umtitel;
private Map<Integer,ArrayList<Recording>> umyear;
public Searcher(Collection<Recording> data)
{
Collection<Recording> recordings = data;
TreeMap<String, Recording> artist = new TreeMap<>();
TreeMap<String, Recording> titel = new TreeMap<>();
TreeMap<String, ArrayList<Recording>> artist = new TreeMap<>();
TreeMap<String, ArrayList<Recording>> titel = new TreeMap<>();
TreeMap<Integer, ArrayList<Recording>> year = new TreeMap<>();
Set<Recording> genre = new TreeSet<Recording>();
for (Recording element : recordings) {
titel.put(element.getTitle(), element);
artist.put(element.getArtist(), element);
// year.put(element.getYear(), element);
ArrayList<Recording> updatedYear = new ArrayList<>();
@ -33,8 +33,22 @@ public class Searcher {
}
updatedYear.add(element);
year.put(element.getYear(), updatedYear);
ArrayList<Recording> updatedTitel = new ArrayList<>();
if (titel.containsKey(element.getTitle())) {
updatedTitel = titel.get(element.getTitle());
}
updatedTitel.add(element);
titel.put(element.getTitle(), updatedTitel);
ArrayList<Recording> updatedArtist = new ArrayList<>();
if (artist.containsKey(element.getArtist())) {
updatedArtist = titel.get(element.getArtist());
}
updatedTitel.add(element);
artist.put(element.getArtist(), updatedArtist);
}
//System.out.println(artist);
@ -54,8 +68,13 @@ public class Searcher {
{
return this.umartist.containsKey(name);
}
public Collection<String> getGenres() {
}
}
/*
TreeMap<String, Recording> titel = new TreeMap<>();

Loading…
Cancel
Save