Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

41
LINES

< > BotCompany Repo | #1031164 // SynchronizedSortedMap

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5358L/29K).

1  
persistable sclass SynchronizedSortedMap<K,V>
2  
    extends SynchronizedMap<K,V>
3  
    is SortedMap<K,V>
4  
{
5  
    SortedMap<K, V> innerMap() { ret (SortedMap) m; }
6  
7  
    SynchronizedSortedMap(SortedMap<K,V> m) {
8  
        super(m);
9  
    }
10  
    SynchronizedSortedMap(SortedMap<K,V> m, Object mutex) {
11  
        super(m, mutex);
12  
    }
13  
14  
    public Comparator<? super K> comparator() {
15  
        synchronized (mutex) {return innerMap().comparator();}
16  
    }
17  
18  
    public SortedMap<K,V> subMap(K fromKey, K toKey) {
19  
        synchronized (mutex) {
20  
            return new SynchronizedSortedMap<>(
21  
                innerMap().subMap(fromKey, toKey), mutex);
22  
        }
23  
    }
24  
    public SortedMap<K,V> headMap(K toKey) {
25  
        synchronized (mutex) {
26  
            return new SynchronizedSortedMap<>(innerMap().headMap(toKey), mutex);
27  
        }
28  
    }
29  
    public SortedMap<K,V> tailMap(K fromKey) {
30  
        synchronized (mutex) {
31  
           return new SynchronizedSortedMap<>(innerMap().tailMap(fromKey),mutex);
32  
        }
33  
    }
34  
35  
    public K firstKey() {
36  
        synchronized (mutex) {return innerMap().firstKey();}
37  
    }
38  
    public K lastKey() {
39  
        synchronized (mutex) {return innerMap().lastKey();}
40  
    }
41  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031164
Snippet name: SynchronizedSortedMap
Eternal ID of this version: #1031164/4
Text MD5: b4dae3003072d12551fea37598005459
Transpilation MD5: f610d52c1e9d6afe27871c125111ec64
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-19 08:21:28
Source code size: 1225 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 126 / 307
Version history: 3 change(s)
Referenced in: [show references]