1 package org.opentrafficsim.core.perception.collections;
2
3 import java.util.Collections;
4 import java.util.Iterator;
5 import java.util.NavigableSet;
6
7 import org.opentrafficsim.core.perception.HistoryManager;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 public abstract class AbstractHistoricalNavigableSet<E, S extends NavigableSet<E>> extends AbstractHistoricalSortedSet<E, S>
27 implements HistoricalNavigableSet<E>
28 {
29
30
31
32
33
34
35 protected AbstractHistoricalNavigableSet(final HistoryManager historyManager, final S set)
36 {
37 super(historyManager, set);
38 }
39
40
41 @Override
42 public String toString()
43 {
44 return "HistoricalNavigableSet [current=" + getCollection() + "]";
45 }
46
47
48
49
50 @Override
51 public E pollFirst()
52 {
53 if (getCollection().isEmpty())
54 {
55 return null;
56 }
57 E element = getCollection().first();
58 remove(element);
59 return element;
60 }
61
62
63 @Override
64 public E pollLast()
65 {
66 if (getCollection().isEmpty())
67 {
68 return null;
69 }
70 E element = getCollection().last();
71 remove(element);
72 return element;
73 }
74
75
76
77
78 @Override
79 public E lower(final E e)
80 {
81 return getCollection().lower(e);
82 }
83
84
85 @Override
86 public E floor(final E e)
87 {
88 return getCollection().floor(e);
89 }
90
91
92 @Override
93 public E ceiling(final E e)
94 {
95 return getCollection().ceiling(e);
96 }
97
98
99 @Override
100 public E higher(final E e)
101 {
102 return getCollection().higher(e);
103 }
104
105
106 @Override
107 public NavigableSet<E> descendingSet()
108 {
109 return Collections.unmodifiableNavigableSet(getCollection().descendingSet());
110 }
111
112
113 @Override
114 public Iterator<E> descendingIterator()
115 {
116 return Collections.unmodifiableNavigableSet(getCollection()).descendingIterator();
117 }
118
119
120 @Override
121 public NavigableSet<E> subSet(final E fromElement, final boolean fromInclusive, final E toElement,
122 final boolean toInclusive)
123 {
124 return Collections.unmodifiableNavigableSet(getCollection().subSet(fromElement, fromInclusive, toElement, toInclusive));
125 }
126
127
128 @Override
129 public NavigableSet<E> headSet(final E toElement, final boolean inclusive)
130 {
131 return Collections.unmodifiableNavigableSet(getCollection().headSet(toElement, inclusive));
132 }
133
134
135 @Override
136 public NavigableSet<E> tailSet(final E fromElement, final boolean inclusive)
137 {
138 return Collections.unmodifiableNavigableSet(getCollection().tailSet(fromElement, inclusive));
139 }
140
141 }