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

98
LINES

< > BotCompany Repo | #1031163 // SynchronizedNavigableMap

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

Libraryless. Click here for Pure Java version (5670L/31K).

persistable sclass SynchronizedNavigableMap<K,V> extends SynchronizedSortedMap<K,V> is NavigableMap<K,V>
{
    NavigableMap<K, V> innerMap() { ret (NavigableMap) m; }

    SynchronizedNavigableMap(NavigableMap<K,V> m) {
        super(m);
    }
    SynchronizedNavigableMap(NavigableMap<K,V> m, Object mutex) {
        super(m, mutex);
    }

    public Entry<K, V> lowerEntry(K key)
                    { synchronized (mutex) { return innerMap().lowerEntry(key); } }
    public K lowerKey(K key)
                      { synchronized (mutex) { return innerMap().lowerKey(key); } }
    public Entry<K, V> floorEntry(K key)
                    { synchronized (mutex) { return innerMap().floorEntry(key); } }
    public K floorKey(K key)
                      { synchronized (mutex) { return innerMap().floorKey(key); } }
    public Entry<K, V> ceilingEntry(K key)
                  { synchronized (mutex) { return innerMap().ceilingEntry(key); } }
    public K ceilingKey(K key)
                    { synchronized (mutex) { return innerMap().ceilingKey(key); } }
    public Entry<K, V> higherEntry(K key)
                   { synchronized (mutex) { return innerMap().higherEntry(key); } }
    public K higherKey(K key)
                     { synchronized (mutex) { return innerMap().higherKey(key); } }
    public Entry<K, V> firstEntry()
                       { synchronized (mutex) { return innerMap().firstEntry(); } }
    public Entry<K, V> lastEntry()
                        { synchronized (mutex) { return innerMap().lastEntry(); } }
    public Entry<K, V> pollFirstEntry()
                   { synchronized (mutex) { return innerMap().pollFirstEntry(); } }
    public Entry<K, V> pollLastEntry()
                    { synchronized (mutex) { return innerMap().pollLastEntry(); } }

    public NavigableMap<K, V> descendingMap() {
        synchronized (mutex) {
            return
                new SynchronizedNavigableMap<>(innerMap().descendingMap(), mutex);
        }
    }

    public NavigableSet<K> keySet() {
        return navigableKeySet();
    }

    public NavigableSet<K> navigableKeySet() {
        synchronized (mutex) {
            return new SynchronizedNavigableSet<>(innerMap().navigableKeySet(), mutex);
        }
    }

    public NavigableSet<K> descendingKeySet() {
        synchronized (mutex) {
            return new SynchronizedNavigableSet<>(innerMap().descendingKeySet(), mutex);
        }
    }


    public SortedMap<K,V> subMap(K fromKey, K toKey) {
        synchronized (mutex) {
            return new SynchronizedNavigableMap<>(
                innerMap().subMap(fromKey, true, toKey, false), mutex);
        }
    }
    public SortedMap<K,V> headMap(K toKey) {
        synchronized (mutex) {
            return new SynchronizedNavigableMap<>(innerMap().headMap(toKey, false), mutex);
        }
    }
    public SortedMap<K,V> tailMap(K fromKey) {
        synchronized (mutex) {
    return new SynchronizedNavigableMap<>(innerMap().tailMap(fromKey, true),mutex);
        }
    }

    public NavigableMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
        synchronized (mutex) {
            return new SynchronizedNavigableMap<>(
                innerMap().subMap(fromKey, fromInclusive, toKey, toInclusive), mutex);
        }
    }

    public NavigableMap<K, V> headMap(K toKey, boolean inclusive) {
        synchronized (mutex) {
            return new SynchronizedNavigableMap<>(
                    innerMap().headMap(toKey, inclusive), mutex);
        }
    }

    public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
        synchronized (mutex) {
            return new SynchronizedNavigableMap<>(
                innerMap().tailMap(fromKey, inclusive), mutex);
        }
    }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1031163
Snippet name: SynchronizedNavigableMap
Eternal ID of this version: #1031163/4
Text MD5: 4343ea7d77f878feb3d9b61f473fbb78
Transpilation MD5: dba6c74403f46d29eebd267621c7d071
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:22:33
Source code size: 3875 bytes / 98 lines
Pitched / IR pitched: No / No
Views / Downloads: 203 / 413
Version history: 3 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)
#1034596 - SynchronizedNavigableMap (backup with extra field)