1 package org.opentrafficsim.road.gtu.lane.perception;
2
3 import java.util.Iterator;
4 import java.util.LinkedHashSet;
5 import java.util.Set;
6 import java.util.SortedSet;
7
8 import org.opentrafficsim.road.gtu.lane.perception.headway.Headway;
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class PerceptionIterableSet<H extends Headway> implements PerceptionIterable<H>
23 {
24
25
26 private Set<H> set;
27
28
29
30
31 public PerceptionIterableSet()
32 {
33 this.set = new LinkedHashSet<>();
34 }
35
36
37
38
39
40 public PerceptionIterableSet(final H headway)
41 {
42 this.set = new LinkedHashSet<>();
43 this.set.add(headway);
44 }
45
46
47
48
49
50 public PerceptionIterableSet(final SortedSet<H> headways)
51 {
52 this.set = headways;
53 }
54
55
56 @Override
57 public Iterator<H> iterator()
58 {
59 return this.set.iterator();
60 }
61
62
63 @Override
64 public H first()
65 {
66 return this.set.iterator().next();
67 }
68
69
70 @Override
71 public boolean isEmpty()
72 {
73 return this.set.isEmpty();
74 }
75
76 }