MATSIM
withinday
replanning
identifiers
filter
LinkFilter.java
Go to the documentation of this file.
1
/* *********************************************************************** *
2
* project: org.matsim.*
3
* LinkFilter.java
4
* *
5
* *********************************************************************** *
6
* *
7
* copyright : (C) 2013 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
21
package
org.matsim.withinday.replanning.identifiers.filter;
22
23
import
java.util.Iterator;
24
import
java.util.Map;
25
import
java.util.Set;
26
27
import
org
.
matsim
.
api
.
core
.
v01
.
Id
;
28
import
org
.
matsim
.
api
.
core
.
v01
.
network
.
Link
;
29
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Person
;
30
import
org
.
matsim
.
core
.
mobsim
.
framework
.
MobsimAgent
;
31
import
org
.
matsim
.
withinday
.
replanning
.
identifiers
.
interfaces
.
AgentFilter
;
32
39
public
class
LinkFilter
implements
AgentFilter
{
40
41
private
final
Map<Id<Person>,
MobsimAgent
>
agents
;
42
private
final
Set<Id<Link>>
links
;
43
44
// use the factory
45
/*package*/
LinkFilter
(Map<
Id<Person>
,
MobsimAgent
> agents, Set<
Id<Link>
> links) {
46
this.agents =
agents
;
47
this.links =
links
;
48
}
49
50
@Override
51
public
void
applyAgentFilter
(Set<
Id<Person>
>
set
,
double
time) {
52
Iterator<Id<Person>> iter =
set
.iterator();
53
54
while
(iter.hasNext()) {
55
Id<Person>
id
= iter.next();
56
if
(!this.
applyAgentFilter
(
id
, time)) iter.remove();
57
}
58
}
59
60
@Override
61
public
boolean
applyAgentFilter
(
Id<Person>
id
,
double
time) {
62
MobsimAgent
agent = this.agents.get(
id
);
63
64
if
(!(links.contains(agent.
getCurrentLinkId
())))
return
false
;
65
else
return
true
;
66
}
67
}
org.matsim.api.core.v01.network
Definition:
Link.java:20
org.matsim.api.core.v01.Id
Definition:
Id.java:44
org.matsim.core.mobsim.framework
Definition:
AbstractMobsimModule.java:22
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.withinday.replanning.identifiers.interfaces
Definition:
AgentFilter.java:21
org
org.matsim.core.mobsim.framework.MobsimAgent
Definition:
MobsimAgent.java:41
org.matsim.core.mobsim.framework.NetworkAgent.getCurrentLinkId
Id< Link > getCurrentLinkId()
org.matsim.core.mobsim
Definition:
DefaultMobsimModule.java:23
org.matsim.api
org.matsim.withinday.replanning.identifiers.filter.LinkFilter.applyAgentFilter
void applyAgentFilter(Set< Id< Person >> set, double time)
Definition:
LinkFilter.java:51
org.matsim.withinday.replanning.identifiers
Definition:
ActivityEndIdentifier.java:21
org.matsim.withinday.replanning
org.matsim.withinday.replanning.identifiers.filter.LinkFilter.links
final Set< Id< Link > > links
Definition:
LinkFilter.java:42
org.matsim.withinday.replanning.identifiers.filter.LinkFilter.agents
final Map< Id< Person >, MobsimAgent > agents
Definition:
LinkFilter.java:41
org.matsim.core
org.matsim.withinday.replanning.identifiers.filter.LinkFilter
Definition:
LinkFilter.java:39
org.matsim.withinday.replanning.identifiers.filter.LinkFilter.applyAgentFilter
boolean applyAgentFilter(Id< Person > id, double time)
Definition:
LinkFilter.java:61
org.matsim.withinday
org.matsim.api.core
org.matsim
org.matsim.api.core.v01.network.Link
Definition:
Link.java:34
org.matsim.api.core.v01.population.Person
Definition:
Person.java:28
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
org.matsim.withinday.replanning.identifiers.interfaces.AgentFilter
Definition:
AgentFilter.java:36
Generated by
1.8.13