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

68
LINES

< > BotCompany Repo | #1009402 // SynchronizedList - unused

JavaX fragment (include)

1  
sclass SynchronizedList<E> extends SynchronizedCollection<E> implements List<E> {
2  
  final List<E> list;
3  
4  
  SynchronizedList(List<E> list) {
5  
      super(list);
6  
      this.list = list;
7  
  }
8  
  SynchronizedList(List<E> list, Object mutex) {
9  
      super(list, mutex);
10  
      this.list = list;
11  
  }
12  
13  
  public boolean equals(Object o) {
14  
      if (this == o)
15  
          return true;
16  
      synchronized (mutex) {return list.equals(o);}
17  
  }
18  
  public int hashCode() {
19  
      synchronized (mutex) {return list.hashCode();}
20  
  }
21  
22  
  public E get(int index) {
23  
      synchronized (mutex) {return list.get(index);}
24  
  }
25  
  public E set(int index, E element) {
26  
      synchronized (mutex) {return list.set(index, element);}
27  
  }
28  
  public void add(int index, E element) {
29  
      synchronized (mutex) {list.add(index, element);}
30  
  }
31  
  public E remove(int index) {
32  
      synchronized (mutex) {return list.remove(index);}
33  
  }
34  
35  
  public int indexOf(Object o) {
36  
      synchronized (mutex) {return list.indexOf(o);}
37  
  }
38  
  public int lastIndexOf(Object o) {
39  
      synchronized (mutex) {return list.lastIndexOf(o);}
40  
  }
41  
42  
  public boolean addAll(int index, Collection<? extends E> c) {
43  
      synchronized (mutex) {return list.addAll(index, c);}
44  
  }
45  
46  
  public ListIterator<E> listIterator() {
47  
      return list.listIterator(); // Must be manually synched by user
48  
  }
49  
50  
  public ListIterator<E> listIterator(int index) {
51  
      return list.listIterator(index); // Must be manually synched by user
52  
  }
53  
54  
  public List<E> subList(int fromIndex, int toIndex) {
55  
      synchronized (mutex) {
56  
          return new SynchronizedList<>(list.subList(fromIndex, toIndex),
57  
                                      mutex);
58  
      }
59  
  }
60  
61  
  /*public void replaceAll(UnaryOperator<E> operator) {
62  
      synchronized (mutex) {list.replaceAll(operator);}
63  
  }*/
64  
  
65  
  public void sort(Comparator<? super E> c) {
66  
      synchronized (mutex) {list.sort(c);}
67  
  }
68  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009402
Snippet name: SynchronizedList - unused
Eternal ID of this version: #1009402/3
Text MD5: 2339fd6fe0ebf8be9b546ab1ec882b12
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-31 22:24:26
Source code size: 1958 bytes / 68 lines
Pitched / IR pitched: No / No
Views / Downloads: 454 / 493
Version history: 2 change(s)
Referenced in: [show references]