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

68
LINES

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

JavaX fragment (include)

sclass SynchronizedList<E> extends SynchronizedCollection<E> implements List<E> {
  final List<E> list;

  SynchronizedList(List<E> list) {
      super(list);
      this.list = list;
  }
  SynchronizedList(List<E> list, Object mutex) {
      super(list, mutex);
      this.list = list;
  }

  public boolean equals(Object o) {
      if (this == o)
          return true;
      synchronized (mutex) {return list.equals(o);}
  }
  public int hashCode() {
      synchronized (mutex) {return list.hashCode();}
  }

  public E get(int index) {
      synchronized (mutex) {return list.get(index);}
  }
  public E set(int index, E element) {
      synchronized (mutex) {return list.set(index, element);}
  }
  public void add(int index, E element) {
      synchronized (mutex) {list.add(index, element);}
  }
  public E remove(int index) {
      synchronized (mutex) {return list.remove(index);}
  }

  public int indexOf(Object o) {
      synchronized (mutex) {return list.indexOf(o);}
  }
  public int lastIndexOf(Object o) {
      synchronized (mutex) {return list.lastIndexOf(o);}
  }

  public boolean addAll(int index, Collection<? extends E> c) {
      synchronized (mutex) {return list.addAll(index, c);}
  }

  public ListIterator<E> listIterator() {
      return list.listIterator(); // Must be manually synched by user
  }

  public ListIterator<E> listIterator(int index) {
      return list.listIterator(index); // Must be manually synched by user
  }

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

  /*public void replaceAll(UnaryOperator<E> operator) {
      synchronized (mutex) {list.replaceAll(operator);}
  }*/
  
  public void sort(Comparator<? super E> c) {
      synchronized (mutex) {list.sort(c);}
  }
}

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: 452 / 489
Version history: 2 change(s)
Referenced in: [show references]