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).

static persistable class SynchronizedRandomAccessList<E>
    extends SynchronizedList<E>
    implements RandomAccess {

    SynchronizedRandomAccessList(List<E> list) {
        super(list);
    }

    SynchronizedRandomAccessList(List<E> list, Object mutex) {
        super(list, mutex);
    }

    public List<E> subList(int fromIndex, int toIndex) {
        synchronized (mutex) {
            return new SynchronizedRandomAccessList<>(
                list.subList(fromIndex, toIndex), mutex);
        }
    }

    @java.io.Serial
    private static final long serialVersionUID = 1530674583602358482L;

    /**
     * Allows instances to be deserialized in pre-1.4 JREs (which do
     * not have SynchronizedRandomAccessList).  SynchronizedList has
     * a readResolve method that inverts this transformation upon
     * deserialization.
     */
    @java.io.Serial
    private Object writeReplace() {
        return new SynchronizedList<>(list);
    }
}

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: 170 / 388
Referenced in: [show references]