Libraryless. Click here for Pure Java version (3023L/17K).
1 | persistable static class SynchronizedNavigableSet<E> |
2 | extends SynchronizedSortedSet<E> |
3 | implements NavigableSet<E> |
4 | {
|
5 | @java.io.Serial |
6 | private static final long serialVersionUID = -5505529816273629798L; |
7 | |
8 | @SuppressWarnings("serial") // Conditionally serializable
|
9 | /*private final*/ NavigableSet<E> ns; |
10 | |
11 | SynchronizedNavigableSet(NavigableSet<E> s) {
|
12 | super(s); |
13 | ns = s; |
14 | } |
15 | |
16 | SynchronizedNavigableSet(NavigableSet<E> s, Object mutex) {
|
17 | super(s, mutex); |
18 | ns = s; |
19 | } |
20 | public E lower(E e) { synchronized (mutex) {return ns.lower(e);} }
|
21 | public E floor(E e) { synchronized (mutex) {return ns.floor(e);} }
|
22 | public E ceiling(E e) { synchronized (mutex) {return ns.ceiling(e);} }
|
23 | public E higher(E e) { synchronized (mutex) {return ns.higher(e);} }
|
24 | public E pollFirst() { synchronized (mutex) {return ns.pollFirst();} }
|
25 | public E pollLast() { synchronized (mutex) {return ns.pollLast();} }
|
26 | |
27 | public NavigableSet<E> descendingSet() {
|
28 | synchronized (mutex) {
|
29 | return new SynchronizedNavigableSet<>(ns.descendingSet(), mutex); |
30 | } |
31 | } |
32 | |
33 | public Iterator<E> descendingIterator() |
34 | { synchronized (mutex) { return descendingSet().iterator(); } }
|
35 | |
36 | public NavigableSet<E> subSet(E fromElement, E toElement) {
|
37 | synchronized (mutex) {
|
38 | return new SynchronizedNavigableSet<>(ns.subSet(fromElement, true, toElement, false), mutex); |
39 | } |
40 | } |
41 | public NavigableSet<E> headSet(E toElement) {
|
42 | synchronized (mutex) {
|
43 | return new SynchronizedNavigableSet<>(ns.headSet(toElement, false), mutex); |
44 | } |
45 | } |
46 | public NavigableSet<E> tailSet(E fromElement) {
|
47 | synchronized (mutex) {
|
48 | return new SynchronizedNavigableSet<>(ns.tailSet(fromElement, true), mutex); |
49 | } |
50 | } |
51 | |
52 | public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
|
53 | synchronized (mutex) {
|
54 | return new SynchronizedNavigableSet<>(ns.subSet(fromElement, fromInclusive, toElement, toInclusive), mutex); |
55 | } |
56 | } |
57 | |
58 | public NavigableSet<E> headSet(E toElement, boolean inclusive) {
|
59 | synchronized (mutex) {
|
60 | return new SynchronizedNavigableSet<>(ns.headSet(toElement, inclusive), mutex); |
61 | } |
62 | } |
63 | |
64 | public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
|
65 | synchronized (mutex) {
|
66 | return new SynchronizedNavigableSet<>(ns.tailSet(fromElement, inclusive), mutex); |
67 | } |
68 | } |
69 | } |
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1031165 |
| Snippet name: | SynchronizedNavigableSet |
| Eternal ID of this version: | #1031165/2 |
| Text MD5: | a6c017f908f5de58466e9d645533d71e |
| Transpilation MD5: | e792316baf5ced9b04520eeecd9b0163 |
| 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:49:17 |
| Source code size: | 2633 bytes / 69 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 405 / 795 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |