MATSIM
PersonHouseholdMapping.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * PersonHouseholdMapping
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 package org.matsim.households;
21 
22 import java.util.Map;
23 
24 import org.matsim.api.core.v01.Id;
25 import org.matsim.api.core.v01.IdMap;
27 
28 
34 public class PersonHouseholdMapping {
35 
36  private final Map<Id<Person>, Household> phMap = new IdMap<>(Person.class);
37 
39  this.reinitialize(hhs);
40  }
41 
42  public void reinitialize(Households hhs) {
43  this.phMap.clear();
44  for (Household h : hhs.getHouseholds().values()){
45  for (Id<Person> member : h.getMemberIds()){
46  this.phMap.put(member, h);
47  }
48  }
49 
50  }
51 
52  public Household getHousehold(Id<Person> personId) {
53  return this.phMap.get(personId);
54  }
55 
56 
57 }
Map< Id< Household >, Household > getHouseholds()
final Map< Id< Person >, Household > phMap