Libraryless. Click here for Pure Java version (2933L/17K).
1 | persistable static class SynchronizedSortedSet<E> |
2 | extends SynchronizedSet<E> |
3 | implements SortedSet<E> |
4 | {
|
5 | @java.io.Serial |
6 | private static final long serialVersionUID = 8695801310862127406L; |
7 | |
8 | @SuppressWarnings("serial") // Conditionally serializable
|
9 | /*private final*/ SortedSet<E> ss; |
10 | |
11 | SynchronizedSortedSet(SortedSet<E> s) {
|
12 | super(s); |
13 | ss = s; |
14 | } |
15 | SynchronizedSortedSet(SortedSet<E> s, Object mutex) {
|
16 | super(s, mutex); |
17 | ss = s; |
18 | } |
19 | |
20 | public Comparator<? super E> comparator() {
|
21 | synchronized (mutex) {return ss.comparator();}
|
22 | } |
23 | |
24 | public SortedSet<E> subSet(E fromElement, E toElement) {
|
25 | synchronized (mutex) {
|
26 | return new SynchronizedSortedSet<>( |
27 | ss.subSet(fromElement, toElement), mutex); |
28 | } |
29 | } |
30 | public SortedSet<E> headSet(E toElement) {
|
31 | synchronized (mutex) {
|
32 | return new SynchronizedSortedSet<>(ss.headSet(toElement), mutex); |
33 | } |
34 | } |
35 | public SortedSet<E> tailSet(E fromElement) {
|
36 | synchronized (mutex) {
|
37 | return new SynchronizedSortedSet<>(ss.tailSet(fromElement),mutex); |
38 | } |
39 | } |
40 | |
41 | public E first() {
|
42 | synchronized (mutex) {return ss.first();}
|
43 | } |
44 | public E last() {
|
45 | synchronized (mutex) {return ss.last();}
|
46 | } |
47 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt, wnsclhtenguj
No comments. add comment
| Snippet ID: | #1031166 |
| Snippet name: | SynchronizedSortedSet |
| Eternal ID of this version: | #1031166/3 |
| Text MD5: | 76c5608efd112509fbc8ff9c99edef74 |
| Transpilation MD5: | 797ca6ad301c72740324bb1d168a6569 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-05-16 17:48:16 |
| Source code size: | 1372 bytes / 47 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 438 / 912 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |