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

33
LINES

< > BotCompany Repo | #1031172 // SynchronizedRandomAccessList

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

Libraryless. Click here for Pure Java version (3042L/18K).

1  
static persistable class SynchronizedRandomAccessList<E>
2  
    extends SynchronizedList<E>
3  
    implements RandomAccess {
4  
5  
    SynchronizedRandomAccessList(List<E> list) {
6  
        super(list);
7  
    }
8  
9  
    SynchronizedRandomAccessList(List<E> list, Object mutex) {
10  
        super(list, mutex);
11  
    }
12  
13  
    public List<E> subList(int fromIndex, int toIndex) {
14  
        synchronized (mutex) {
15  
            return new SynchronizedRandomAccessList<>(
16  
                list.subList(fromIndex, toIndex), mutex);
17  
        }
18  
    }
19  
20  
    @java.io.Serial
21  
    private static final long serialVersionUID = 1530674583602358482L;
22  
23  
    /**
24  
     * Allows instances to be deserialized in pre-1.4 JREs (which do
25  
     * not have SynchronizedRandomAccessList).  SynchronizedList has
26  
     * a readResolve method that inverts this transformation upon
27  
     * deserialization.
28  
     */
29  
    @java.io.Serial
30  
    private Object writeReplace() {
31  
        return new SynchronizedList<>(list);
32  
    }
33  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1031172
Snippet name: SynchronizedRandomAccessList
Eternal ID of this version: #1031172/1
Text MD5: 1b9b8f2075f3bfa4de316e88d577c344
Transpilation MD5: 1ccc0a78b19e0f1deae40a089c07a1f2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-16 18:02:23
Source code size: 991 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 171 / 391
Referenced in: [show references]