@Override public void clear() { listOps.trim(size() + 1, 0); }
@Override public E get(int index) { if (index < 0 || index > size()) { throw new IndexOutOfBoundsException(); } return listOps.index(index); }
@Override public int drainTo(Collection<? super E> c) { return drainTo(c, size()); }
@Override public int drainTo(Collection<? super E> c, int maxElements) { if (this.equals(c)) { throw new IllegalArgumentException("Cannot drain a queue to itself"); } int size = size(); int loop = (size >= maxElements ? maxElements : size); for (int index = 0; index < loop; index++) { c.add(poll()); } return loop; }
@Override public void add(int index, E element) { if (index == 0) { listOps.leftPush(element); cap(); return; } int size = size(); if (index == size()) { listOps.rightPush(element); cap(); return; } if (index < 0 || index > size) { throw new IndexOutOfBoundsException(); } throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list"); }
@Override public boolean addAll(int index, Collection<? extends E> c) { // insert collection in reverse if (index == 0) { Collection<? extends E> reverseC = CollectionUtils.reverse(c); for (E e : reverseC) { listOps.leftPush(e); cap(); } return true; } int size = size(); if (index == size()) { for (E e : c) { listOps.rightPush(e); cap(); } return true; } if (index < 0 || index > size) { throw new IndexOutOfBoundsException(); } throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list"); }
@Override public E get(int index) { if (index < 0 || index > size()) { throw new IndexOutOfBoundsException(); } return listOps.index(index); }
@Override public E get(int index) { if (index < 0 || index > size()) { throw new IndexOutOfBoundsException(); } return listOps.index(index); }
@Override public void clear() { listOps.trim(size() + 1, 0); }
@Override public int drainTo(Collection<? super E> c) { return drainTo(c, size()); }
@Override public void clear() { listOps.trim(size() + 1, 0); }
@Override public int drainTo(Collection<? super E> c) { return drainTo(c, size()); }
@Override public int drainTo(Collection<? super E> c, int maxElements) { if (this.equals(c)) { throw new IllegalArgumentException("Cannot drain a queue to itself"); } int size = size(); int loop = (size >= maxElements ? maxElements : size); for (int index = 0; index < loop; index++) { c.add(poll()); } return loop; }
@Override public int drainTo(Collection<? super E> c, int maxElements) { if (this.equals(c)) { throw new IllegalArgumentException("Cannot drain a queue to itself"); } int size = size(); int loop = (size >= maxElements ? maxElements : size); for (int index = 0; index < loop; index++) { c.add(poll()); } return loop; }
@Override public void add(int index, E element) { if (index == 0) { listOps.leftPush(element); cap(); return; } int size = size(); if (index == size()) { listOps.rightPush(element); cap(); return; } if (index < 0 || index > size) { throw new IndexOutOfBoundsException(); } throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list"); }
@Override public void add(int index, E element) { if (index == 0) { listOps.leftPush(element); cap(); return; } int size = size(); if (index == size()) { listOps.rightPush(element); cap(); return; } if (index < 0 || index > size) { throw new IndexOutOfBoundsException(); } throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list"); }
@Override public boolean addAll(int index, Collection<? extends E> c) { // insert collection in reverse if (index == 0) { Collection<? extends E> reverseC = CollectionUtils.reverse(c); for (E e : reverseC) { listOps.leftPush(e); cap(); } return true; } int size = size(); if (index == size()) { for (E e : c) { listOps.rightPush(e); cap(); } return true; } if (index < 0 || index > size) { throw new IndexOutOfBoundsException(); } throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list"); }
@Override public boolean addAll(int index, Collection<? extends E> c) { // insert collection in reverse if (index == 0) { Collection<? extends E> reverseC = CollectionUtils.reverse(c); for (E e : reverseC) { listOps.leftPush(e); cap(); } return true; } int size = size(); if (index == size()) { for (E e : c) { listOps.rightPush(e); cap(); } return true; } if (index < 0 || index > size) { throw new IndexOutOfBoundsException(); } throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list"); }