Javolution 6.0.0 java
SortedMapView.java
Go to the documentation of this file.
1 /*
2  * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
3  * Copyright (C) 2012 - Javolution (http://javolution.org/)
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software is
7  * freely granted, provided that this notice is preserved.
8  */
9 package javolution.util.internal.map.sorted;
10 
11 import java.util.Comparator;
12 import java.util.Map;
13 
19 
24 public abstract class SortedMapView<K,V> extends MapView<K,V> implements SortedMapService<K,V> {
25 
27  protected class EntrySortedSet extends EntrySet implements SortedSetService<Entry<K,V>> {
28  private static final long serialVersionUID = SortedMapView.serialVersionUID;
29 
30  @Override
31  public Entry<K, V> first() {
32  K key = SortedMapView.this.firstKey();
33  V value = SortedMapView.this.get(key);
34  return new MapEntryImpl<K,V>(key, value);
35  }
36 
37  @Override
38  public SortedSetService<Entry<K, V>> headSet(Entry<K, V> toElement) {
39  return new SubSortedSetImpl<Entry<K, V>>(this, null, toElement);
40  }
41 
42  @Override
43  public java.util.Map.Entry<K, V> last() {
44  K key = SortedMapView.this.lastKey();
45  V value = SortedMapView.this.get(key);
46  return new MapEntryImpl<K,V>(key, value);
47  }
48 
49  @Override
50  public SortedSetService<java.util.Map.Entry<K, V>> subSet(
51  Entry<K, V> fromElement,
52  Entry<K, V> toElement) {
53  return new SubSortedSetImpl<Entry<K, V>>(this, fromElement, toElement);
54  }
55 
56  @Override
57  public SortedSetService<Entry<K, V>> tailSet(Entry<K, V> fromElement) {
58  return new SubSortedSetImpl<Entry<K, V>>(this, fromElement, null);
59  }
60 
61  @Override
63  return new SharedSortedSetImpl<Entry<K, V>>(this);
64  }
65  }
66 
68  protected class KeySortedSet extends KeySet implements SortedSetService<K> {
69  private static final long serialVersionUID = SortedMapView.serialVersionUID;
70 
71  @Override
72  public K first() {
73  return SortedMapView.this.firstKey();
74  }
75 
76  @Override
77  public SortedSetService<K> headSet(K toElement) {
78  return new SubSortedSetImpl<K>(this, null, toElement);
79  }
80 
81  @Override
82  public K last() {
83  return SortedMapView.this.lastKey();
84  }
85 
86  @Override
87  public SortedSetService<K> subSet(K fromElement, K toElement) {
88  return new SubSortedSetImpl<K>(this, fromElement, toElement);
89  }
90 
91  @Override
92  public SortedSetService<K> tailSet(K fromElement) {
93  return new SubSortedSetImpl<K>(this, fromElement, null);
94  }
95 
96  @Override
98  return new SharedSortedSetImpl<K>(this);
99  }
100  }
101 
102  private static final long serialVersionUID = 0x600L; // Version.
103 
108  super(target);
109  }
110 
111  @Override
112  public Comparator<? super K> comparator() {
113  return keyComparator();
114  }
115 
116  @Override
117  public SortedSetService<Map.Entry<K, V>> entrySet() {
118  return new EntrySortedSet();
119  }
120 
121  @Override
122  public abstract K firstKey();
123 
124  @Override
125  public SortedMapService<K, V> headMap(K toKey) {
126  return new SubSortedMapImpl<K,V>(this, firstKey(), toKey);
127  }
128 
129  @Override
131  return new KeySortedSet();
132  }
133 
134  @Override
135  public abstract K lastKey();
136 
137  @Override
138  public SortedMapService<K, V> subMap(K fromKey, K toKey) {
139  return new SubSortedMapImpl<K,V>(this, fromKey, toKey);
140  }
141 
142  @Override
143  public SortedMapService<K, V> tailMap(K fromKey) {
144  return new SubSortedMapImpl<K,V>(this, fromKey, lastKey());
145  }
146 
147  @Override
149  return new SharedSortedMapImpl<K,V>(this);
150  }
151 
153  @Override
155  return (SortedMapService<K,V>) super.target();
156  }
157 }
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet.threadSafe
SortedSetService< K > threadSafe()
Definition: SortedMapView.java:97
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet
Definition: SortedMapView.java:68
javolution
javolution.util.internal
javolution.util.internal.map.sorted.MapEntryImpl
Definition: sorted/MapEntryImpl.java:17
javolution.util.service
Definition: BitSetService.java:9
javolution.util.internal.map.MapView.KeySet
Definition: MapView.java:153
javolution.util.service.SortedSetService
Definition: SortedSetService.java:19
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet.tailSet
SortedSetService< K > tailSet(K fromElement)
Definition: SortedMapView.java:92
javolution.util.internal.set.sorted.SubSortedSetImpl
Definition: SubSortedSetImpl.java:20
javolution.util.internal.map.MapView
Definition: MapView.java:29
javolution.util.internal.set
Definition: AtomicSetImpl.java:9
javolution.util.service.SortedMapService
Definition: SortedMapService.java:21
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet.first
K first()
Definition: SortedMapView.java:72
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet.serialVersionUID
static final long serialVersionUID
Definition: SortedMapView.java:69
javolution.util.internal.map.sorted.SortedMapView.keySet
SortedSetService< K > keySet()
Definition: SortedMapView.java:130
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet.threadSafe
SortedSetService< Entry< K, V > > threadSafe()
Definition: SortedMapView.java:62
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet.headSet
SortedSetService< K > headSet(K toElement)
Definition: SortedMapView.java:77
javolution.util.internal.map.sorted.SubSortedMapImpl
Definition: SubSortedMapImpl.java:20
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet.serialVersionUID
static final long serialVersionUID
Definition: SortedMapView.java:28
javolution.util.internal.map.sorted.SharedSortedMapImpl
Definition: SharedSortedMapImpl.java:21
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet.subSet
SortedSetService< java.util.Map.Entry< K, V > > subSet(Entry< K, V > fromElement, Entry< K, V > toElement)
Definition: SortedMapView.java:50
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet.headSet
SortedSetService< Entry< K, V > > headSet(Entry< K, V > toElement)
Definition: SortedMapView.java:38
javolution.util.internal.map.sorted.SortedMapView.subMap
SortedMapService< K, V > subMap(K fromKey, K toKey)
Definition: SortedMapView.java:138
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet.subSet
SortedSetService< K > subSet(K fromElement, K toElement)
Definition: SortedMapView.java:87
javolution.util.internal.map.sorted.SortedMapView.threadSafe
SortedMapService< K, V > threadSafe()
Definition: SortedMapView.java:148
javolution.util.internal.map.sorted.SortedMapView.comparator
Comparator<? super K > comparator()
Definition: SortedMapView.java:112
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet
Definition: SortedMapView.java:27
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet.last
java.util.Map.Entry< K, V > last()
Definition: SortedMapView.java:43
javolution.util.internal.map.sorted.SortedMapView.headMap
SortedMapService< K, V > headMap(K toKey)
Definition: SortedMapView.java:125
javolution.util.internal.map.sorted.SortedMapView.SortedMapView
SortedMapView(SortedMapService< K, V > target)
Definition: SortedMapView.java:107
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet.first
Entry< K, V > first()
Definition: SortedMapView.java:31
javolution.util.internal.map.sorted.SortedMapView.firstKey
abstract K firstKey()
javolution.util.internal.set.sorted
Definition: AtomicSortedSetImpl.java:9
EntrySet
javolution.util.internal.map.sorted.SortedMapView.tailMap
SortedMapService< K, V > tailMap(K fromKey)
Definition: SortedMapView.java:143
javolution.util.internal.set.sorted.SharedSortedSetImpl
Definition: SharedSortedSetImpl.java:19
javolution.util.internal.map.sorted.SortedMapView.EntrySortedSet.tailSet
SortedSetService< Entry< K, V > > tailSet(Entry< K, V > fromElement)
Definition: SortedMapView.java:57
javolution.util.internal.map.sorted.SortedMapView.serialVersionUID
static final long serialVersionUID
Definition: SortedMapView.java:102
javolution.util.internal.map.sorted.SortedMapView.target
SortedMapService< K, V > target()
Definition: SortedMapView.java:154
javolution.util.internal.map.sorted.SortedMapView
Definition: SortedMapView.java:24
javolution.util.internal.map.sorted.SortedMapView.KeySortedSet.last
K last()
Definition: SortedMapView.java:82
javolution.util
Definition: FastBitSet.java:9
javolution.util.internal.map.MapView.keyComparator
abstract Equality<? super K > keyComparator()
javolution.util.internal.map
Definition: AtomicMapImpl.java:9
javolution.util.internal.map.sorted.SortedMapView.entrySet
SortedSetService< Map.Entry< K, V > > entrySet()
Definition: SortedMapView.java:117
javolution.util.internal.map.MapView.get
abstract V get(Object key)
javolution.util.internal.map.sorted.SortedMapView.lastKey
abstract K lastKey()