JavaCAD
IntegerArrayList.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 2014, Oracle and/or its affiliates.
3  * All rights reserved. Use is subject to license terms.
4  *
5  * This file is available and licensed under the following license:
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * - Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * - Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the distribution.
16  * - Neither the name of Oracle Corporation nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 package eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj;
33 
34 
35 import java.util.AbstractList;
36 import java.util.Arrays;
37 import java.util.Collection;
38 import java.util.Collections;
39 import java.util.ConcurrentModificationException;
40 import java.util.Iterator;
41 import java.util.LinkedList;
42 import java.util.List;
43 import java.util.ListIterator;
44 import java.util.NoSuchElementException;
45 import java.util.RandomAccess;
46 import java.util.Vector;
47 
48 
49 // TODO: Auto-generated Javadoc
102 public class IntegerArrayList extends AbstractList<Integer>
103  implements List<Integer>, RandomAccess, Cloneable, java.io.Serializable {
104 
109  private transient int[] elementData;
110 
116  private int size;
117 
124  public IntegerArrayList(int initialCapacity) {
125  super();
126  if (initialCapacity < 0) {
127  throw new IllegalArgumentException(
128  "Illegal Capacity: " +
129  initialCapacity);
130  }
131  this.elementData = new int[initialCapacity];
132  }
133 
135  public IntegerArrayList() {
136  this(10);
137  }
138 
146  public IntegerArrayList(Collection<? extends Integer> c) {
147  elementData = new int[c.size()];
148  int i = 0;
149  for (Integer d : c) {
150  elementData[i] = d;
151  i++;
152  }
153  size = elementData.length;
154  }
155 
160  public void trimToSize() {
161  modCount++;
162  int oldCapacity = elementData.length;
163  if (size < oldCapacity) {
164  elementData = Arrays.copyOf(elementData, size);
165  }
166  }
167 
174  public void ensureCapacity(int minCapacity) {
175  if (minCapacity > 0) {
176  ensureCapacityInternal(minCapacity);
177  }
178  }
179 
185  private void ensureCapacityInternal(int minCapacity) {
186  modCount++;
187  // overflow-conscious code
188  if (minCapacity - elementData.length > 0) {
189  grow(minCapacity);
190  }
191  }
192 
197  private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
198 
205  private void grow(int minCapacity) {
206  // overflow-conscious code
207  int oldCapacity = elementData.length;
208  int newCapacity = oldCapacity + (oldCapacity >> 1);
209  if (newCapacity - minCapacity < 0)
210  newCapacity = minCapacity;
211  if (newCapacity - MAX_ARRAY_SIZE > 0)
212  newCapacity = hugeCapacity(minCapacity);
213  // minCapacity is usually close to size, so this is a win:
214  elementData = Arrays.copyOf(elementData, newCapacity);
215  }
216 
223  private static int hugeCapacity(int minCapacity) {
224  if (minCapacity < 0) // overflow
225  throw new OutOfMemoryError();
226  return (minCapacity > MAX_ARRAY_SIZE) ?
227  Integer.MAX_VALUE :
229  }
230 
236  @Override public int size() {
237  return size;
238  }
239 
245  @Override public boolean isEmpty() {
246  return size == 0;
247  }
248 
256  @Override public boolean contains(Object o) {
257  return indexOf(o) >= 0;
258  }
259 
268  @Override public int indexOf(Object o) {
269  if (o instanceof Integer) {
270  for (int i = 0; i < size; i++) {
271  if (o.equals(elementData[i])) {
272  return i;
273  }
274  }
275  }
276  return -1;
277  }
278 
287  @Override public int lastIndexOf(Object o) {
288  if (o instanceof Integer) {
289  for (int i = size - 1; i >= 0; i--)
290  if (o.equals(elementData[i]))
291  return i;
292  }
293  return -1;
294  }
295 
301  @Override public Object clone() {
302  try {
303  @SuppressWarnings("unchecked")
305  v.elementData = Arrays.copyOf(elementData, size);
306  v.modCount = 0;
307  return v;
308  } catch (CloneNotSupportedException e) {
309  // this shouldn't happen, since we are Cloneable
310  throw new InternalError();
311  }
312  }
313 
324  @Override public Object[] toArray() {
325  Integer[] array = new Integer[size];
326  for (int i = 0; i < size; i++) {
327  array[i] = elementData[i];
328  }
329  return array;
330  }
331 
351  @SuppressWarnings("unchecked")
352  @Override public <T> T[] toArray(T[] a) {
353  if (a.length < size) {
354  // Make a new array of a's runtime type, but my contents:
355  return (T[]) Arrays.copyOf(toArray(), size, a.getClass());
356  }
357  System.arraycopy(elementData, 0, a, 0, size);
358  if (a.length > size)
359  a[size] = null;
360  return a;
361  }
362 
368  public int[] toIntArray() {
369  int[] res = new int[size];
370  System.arraycopy(elementData, 0, res, 0, size);
371  return res;
372  }
373 
374  // Positional Access Operations
375 
382  @SuppressWarnings("unchecked") Integer elementData(int index) {
383  return (Integer) elementData[index];
384  }
385 
393  @Override public Integer get(int index) {
394  rangeCheck(index);
395 
396  return elementData(index);
397  }
398 
407  @Override public Integer set(int index, Integer element) {
408  rangeCheck(index);
409 
410  Integer oldValue = elementData(index);
411  elementData[index] = element;
412  return oldValue;
413  }
414 
421  @Override public boolean add(Integer e) {
422  ensureCapacityInternal(size + 1); // Increments modCount!!
423  elementData[size++] = e;
424  return true;
425  }
426 
435  @Override public void add(int index, Integer element) {
436  rangeCheckForAdd(index);
437 
438  ensureCapacityInternal(size + 1); // Increments modCount!!
439  System.arraycopy(
440  elementData, index, elementData, index + 1,
441  size - index);
442  elementData[index] = element;
443  size++;
444  }
445 
454  @Override public Integer remove(int index) {
455  rangeCheck(index);
456 
457  modCount++;
458  Integer oldValue = elementData(index);
459 
460  int numMoved = size - index - 1;
461  if (numMoved > 0)
462  System.arraycopy(
463  elementData, index + 1, elementData, index,
464  numMoved);
465  elementData[--size] = 0; // Forget the item completely
466 
467  return oldValue;
468  }
469 
480  @Override public boolean remove(Object o) {
481  if (o instanceof Integer) {
482  for (int index = 0; index < size; index++)
483  if (o.equals(elementData[index])) {
484  fastRemove(index);
485  return true;
486  }
487  }
488  return false;
489  }
490 
496  /*
497  * Private remove method that skips bounds checking and does not
498  * return the value removed.
499  */
500  private void fastRemove(int index) {
501  modCount++;
502  int numMoved = size - index - 1;
503  if (numMoved > 0)
504  System.arraycopy(
505  elementData, index + 1, elementData, index,
506  numMoved);
507  elementData[--size] = 0; // Forget the item completely
508  }
509 
511  @Override public void clear() {
512  modCount++;
513 
514  // Forget the items completely
515  for (int i = 0; i < size; i++)
516  elementData[i] = 0;
517 
518  size = 0;
519  }
520 
531  @Override public boolean addAll(Collection<? extends Integer> c) {
532  Object[] a = c.toArray();
533  int numNew = a.length;
534  ensureCapacityInternal(size + numNew); // Increments modCount
535  System.arraycopy(a, 0, elementData, size, numNew);
536  size += numNew;
537  return numNew != 0;
538  }
539 
552  @Override public boolean addAll(int index, Collection<? extends Integer> c) {
553  rangeCheckForAdd(index);
554 
555  Object[] a = c.toArray();
556  int numNew = a.length;
557  ensureCapacityInternal(size + numNew); // Increments modCount
558 
559  int numMoved = size - index;
560  if (numMoved > 0)
561  System.arraycopy(
562  elementData, index, elementData, index + numNew,
563  numMoved);
564 
565  System.arraycopy(a, 0, elementData, index, numNew);
566  size += numNew;
567  return numNew != 0;
568  }
569 
580  @Override protected void removeRange(int fromIndex, int toIndex) {
581  modCount++;
582  int numMoved = size - toIndex;
583  System.arraycopy(
584  elementData, toIndex, elementData, fromIndex,
585  numMoved);
586 
587  // Forget the item completely
588  int newSize = size - (toIndex - fromIndex);
589  while (size != newSize)
590  elementData[--size] = 0;
591  }
592 
600  private void rangeCheck(int index) {
601  if (index >= size)
602  throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
603  }
604 
610  private void rangeCheckForAdd(int index) {
611  if (index > size || index < 0)
612  throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
613  }
614 
622  private String outOfBoundsMsg(int index) {
623  return "Index: " + index + ", Size: " + size;
624  }
625 
638  @Override public boolean removeAll(Collection<?> c) {
639  return batchRemove(c, false);
640  }
641 
655  @Override public boolean retainAll(Collection<?> c) {
656  return batchRemove(c, true);
657  }
658 
666  private boolean batchRemove(Collection<?> c, boolean complement) {
667  final int[] elementData = this.elementData;
668  int r = 0, w = 0;
669  boolean modified = false;
670  try {
671  for (; r < size; r++)
672  if (c.contains(elementData[r]) == complement)
673  elementData[w++] = elementData[r];
674  } finally {
675  // Preserve behavioral compatibility with AbstractCollection,
676  // even if c.contains() throws.
677  if (r != size) {
678  System.arraycopy(
679  elementData, r,
680  elementData, w,
681  size - r);
682  w += size - r;
683  }
684  if (w != size) {
685  for (int i = w; i < size; i++)
686  elementData[i] = 0;
687  modCount += size - w;
688  size = w;
689  modified = true;
690  }
691  }
692  return modified;
693  }
694 
702  private void writeObject(java.io.ObjectOutputStream s)
703  throws java.io.IOException {
704  // Write out element count, and any hidden stuff
705  int expectedModCount = modCount;
706  s.defaultWriteObject();
707 
708  // Write out array length
709  s.writeInt(elementData.length);
710 
711  // Write out all elements in the proper order.
712  for (int i = 0; i < size; i++)
713  s.writeObject(elementData[i]);
714 
715  if (modCount != expectedModCount) {
716  throw new ConcurrentModificationException();
717  }
718 
719  }
720 
727  private void readObject(java.io.ObjectInputStream s)
728  throws java.io.IOException, ClassNotFoundException {
729  // Read in size, and any hidden stuff
730  s.defaultReadObject();
731 
732  // Read in array length and allocate array
733  int arrayLength = s.readInt();
734  int[] a = elementData = new int[arrayLength];
735 
736  // Read in all elements in the proper order.
737  for (int i = 0; i < size; i++)
738  a[i] = (Integer) s.readObject();
739  }
740 
752  @Override public ListIterator<Integer> listIterator(int index) {
753  if (index < 0 || index > size)
754  throw new IndexOutOfBoundsException("Index: " + index);
755  return new ListItr(index);
756  }
757 
765  @Override public ListIterator<Integer> listIterator() {
766  return new ListItr(0);
767  }
768 
775  @Override public Iterator<Integer> iterator() {
776  return new Itr();
777  }
778 
780  private class Itr implements Iterator<Integer> {
781 
783  int cursor; // index of next element to return
784 
786  int lastRet = -1; // index of last element returned; -1 if no such
787 
789  int expectedModCount = modCount;
790 
791  /* (non-Javadoc)
792  * @see java.util.Iterator#hasNext()
793  */
794  @Override public boolean hasNext() {
795  return cursor != size;
796  }
797 
798  /* (non-Javadoc)
799  * @see java.util.Iterator#next()
800  */
801  @SuppressWarnings("unchecked")
802  @Override public Integer next() {
803  checkForComodification();
804  int i = cursor;
805  if (i >= size)
806  throw new NoSuchElementException();
808  if (i >= elementData.length)
809  throw new ConcurrentModificationException();
810  cursor = i + 1;
811  return (Integer) elementData[lastRet = i];
812  }
813 
814  /* (non-Javadoc)
815  * @see java.util.Iterator#remove()
816  */
817  @Override public void remove() {
818  if (lastRet < 0)
819  throw new IllegalStateException();
820  checkForComodification();
821 
822  try {
823  IntegerArrayList.this.remove(lastRet);
824  cursor = lastRet;
825  lastRet = -1;
826  expectedModCount = modCount;
827  } catch (IndexOutOfBoundsException ex) {
828  throw new ConcurrentModificationException();
829  }
830  }
831 
835  final void checkForComodification() {
836  if (modCount != expectedModCount)
837  throw new ConcurrentModificationException();
838  }
839  }
840 
842  private class ListItr extends Itr implements ListIterator<Integer> {
843 
849  ListItr(int index) {
850  super();
851  cursor = index;
852  }
853 
854  /* (non-Javadoc)
855  * @see java.util.ListIterator#hasPrevious()
856  */
857  @Override public boolean hasPrevious() {
858  return cursor != 0;
859  }
860 
861  /* (non-Javadoc)
862  * @see java.util.ListIterator#nextIndex()
863  */
864  @Override public int nextIndex() {
865  return cursor;
866  }
867 
868  /* (non-Javadoc)
869  * @see java.util.ListIterator#previousIndex()
870  */
871  @Override public int previousIndex() {
872  return cursor - 1;
873  }
874 
875  /* (non-Javadoc)
876  * @see java.util.ListIterator#previous()
877  */
878  @SuppressWarnings("unchecked")
879  @Override public Integer previous() {
880  checkForComodification();
881  int i = cursor - 1;
882  if (i < 0)
883  throw new NoSuchElementException();
885  if (i >= elementData.length)
886  throw new ConcurrentModificationException();
887  cursor = i;
888  return (Integer) elementData[lastRet = i];
889  }
890 
891  /* (non-Javadoc)
892  * @see java.util.ListIterator#set(java.lang.Object)
893  */
894  @Override public void set(Integer e) {
895  if (lastRet < 0)
896  throw new IllegalStateException();
897  checkForComodification();
898 
899  try {
900  IntegerArrayList.this.set(lastRet, e);
901  } catch (IndexOutOfBoundsException ex) {
902  throw new ConcurrentModificationException();
903  }
904  }
905 
906  /* (non-Javadoc)
907  * @see java.util.ListIterator#add(java.lang.Object)
908  */
909  @Override public void add(Integer e) {
910  checkForComodification();
911 
912  try {
913  int i = cursor;
914  IntegerArrayList.this.add(i, e);
915  cursor = i + 1;
916  lastRet = -1;
917  expectedModCount = modCount;
918  } catch (IndexOutOfBoundsException ex) {
919  throw new ConcurrentModificationException();
920  }
921  }
922  }
923 
950  @Override public List<Integer> subList(int fromIndex, int toIndex) {
951  subListRangeCheck(fromIndex, toIndex, size);
952  return new IntegerArrayList.SubList(this, 0, fromIndex, toIndex);
953  }
954 
962  static void subListRangeCheck(int fromIndex, int toIndex, int size) {
963  if (fromIndex < 0)
964  throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
965  if (toIndex > size)
966  throw new IndexOutOfBoundsException("toIndex = " + toIndex);
967  if (fromIndex > toIndex)
968  throw new IllegalArgumentException(
969  "fromIndex(" + fromIndex +
970  ") > toIndex(" + toIndex + ")");
971  }
972 
976  private class SubList extends IntegerArrayList implements RandomAccess {
977 
979  private final IntegerArrayList parent;
980 
982  private final int parentOffset;
983 
985  private final int offset;
986 
988  int size;
989 
998  SubList(
1000  int offset, int fromIndex, int toIndex) {
1001  this.parent = parent;
1002  this.parentOffset = fromIndex;
1003  this.offset = offset + fromIndex;
1004  this.size = toIndex - fromIndex;
1005  this.modCount = IntegerArrayList.this.modCount;
1006  }
1007 
1008  /* (non-Javadoc)
1009  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#toIntArray()
1010  */
1011  @Override
1012  public int[] toIntArray() {
1013  int[] res = new int[size];
1014  System.arraycopy(elementData, offset, res, 0, size);
1015  return res;
1016  }
1017 
1018  /* (non-Javadoc)
1019  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#set(int, java.lang.Integer)
1020  */
1021  @Override public Integer set(int index, Integer e) {
1022  rangeCheck(index);
1024  Integer oldValue = IntegerArrayList.this.elementData(offset + index);
1025  IntegerArrayList.this.elementData[offset + index] = e;
1026  return oldValue;
1027  }
1028 
1029  /* (non-Javadoc)
1030  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#get(int)
1031  */
1032  @Override public Integer get(int index) {
1033  rangeCheck(index);
1035  return IntegerArrayList.this.elementData(offset + index);
1036  }
1037 
1038  /* (non-Javadoc)
1039  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#size()
1040  */
1041  @Override public int size() {
1043  return this.size;
1044  }
1045 
1046  /* (non-Javadoc)
1047  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#add(int, java.lang.Integer)
1048  */
1049  @Override public void add(int index, Integer e) {
1050  rangeCheckForAdd(index);
1052  parent.add(parentOffset + index, e);
1053  this.modCount = parent.modCount;
1054  this.size++;
1055  }
1056 
1057  /* (non-Javadoc)
1058  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#remove(int)
1059  */
1060  @Override public Integer remove(int index) {
1061  rangeCheck(index);
1063  Integer result = parent.remove(parentOffset + index);
1064  this.modCount = parent.modCount;
1065  this.size--;
1066  return result;
1067  }
1068 
1069  /* (non-Javadoc)
1070  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#removeRange(int, int)
1071  */
1072  @Override protected void removeRange(int fromIndex, int toIndex) {
1075  parentOffset + fromIndex,
1076  parentOffset + toIndex);
1077  this.modCount = parent.modCount;
1078  this.size -= toIndex - fromIndex;
1079  }
1080 
1081  /* (non-Javadoc)
1082  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#addAll(java.util.Collection)
1083  */
1084  @Override public boolean addAll(Collection<? extends Integer> c) {
1085  return addAll(this.size, c);
1086  }
1087 
1088  /* (non-Javadoc)
1089  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#addAll(int, java.util.Collection)
1090  */
1091  @Override public boolean addAll(int index, Collection<? extends Integer> c) {
1092  rangeCheckForAdd(index);
1093  int cSize = c.size();
1094  if (cSize == 0)
1095  return false;
1096 
1098  parent.addAll(parentOffset + index, c);
1099  this.modCount = parent.modCount;
1100  this.size += cSize;
1101  return true;
1102  }
1103 
1104  /* (non-Javadoc)
1105  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#iterator()
1106  */
1107  @Override public Iterator<Integer> iterator() {
1108  return listIterator();
1109  }
1110 
1111  /* (non-Javadoc)
1112  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#listIterator(int)
1113  */
1114  @Override public ListIterator<Integer> listIterator(final int index) {
1116  rangeCheckForAdd(index);
1117  final int offset = this.offset;
1118 
1119  return new ListIterator<Integer>() {
1120  int cursor = index;
1121  int lastRet = -1;
1122  int expectedModCount = IntegerArrayList.this.modCount;
1123 
1124  @Override public boolean hasNext() {
1125  return cursor != IntegerArrayList.SubList.this.size;
1126  }
1127 
1128  @SuppressWarnings("unchecked")
1129  @Override public Integer next() {
1131  int i = cursor;
1132  if (i >= IntegerArrayList.SubList.this.size)
1133  throw new NoSuchElementException();
1135  if (offset + i >= elementData.length)
1136  throw new ConcurrentModificationException();
1137  cursor = i + 1;
1138  return (Integer) elementData[offset + (lastRet = i)];
1139  }
1140 
1141  @Override public boolean hasPrevious() {
1142  return cursor != 0;
1143  }
1144 
1145  @SuppressWarnings("unchecked")
1146  @Override public Integer previous() {
1148  int i = cursor - 1;
1149  if (i < 0)
1150  throw new NoSuchElementException();
1152  if (offset + i >= elementData.length)
1153  throw new ConcurrentModificationException();
1154  cursor = i;
1155  return (Integer) elementData[offset + (lastRet = i)];
1156  }
1157 
1158  @Override public int nextIndex() {
1159  return cursor;
1160  }
1161 
1162  @Override public int previousIndex() {
1163  return cursor - 1;
1164  }
1165 
1166  @Override public void remove() {
1167  if (lastRet < 0)
1168  throw new IllegalStateException();
1170 
1171  try {
1172  IntegerArrayList.SubList.this.remove(lastRet);
1173  cursor = lastRet;
1174  lastRet = -1;
1175  expectedModCount = IntegerArrayList.this.modCount;
1176  } catch (IndexOutOfBoundsException ex) {
1177  throw new ConcurrentModificationException();
1178  }
1179  }
1180 
1181  @Override public void set(Integer e) {
1182  if (lastRet < 0)
1183  throw new IllegalStateException();
1185 
1186  try {
1187  IntegerArrayList.this.set(offset + lastRet, e);
1188  } catch (IndexOutOfBoundsException ex) {
1189  throw new ConcurrentModificationException();
1190  }
1191  }
1192 
1193  @Override public void add(Integer e) {
1195 
1196  try {
1197  int i = cursor;
1198  IntegerArrayList.SubList.this.add(i, e);
1199  cursor = i + 1;
1200  lastRet = -1;
1201  expectedModCount = IntegerArrayList.this.modCount;
1202  } catch (IndexOutOfBoundsException ex) {
1203  throw new ConcurrentModificationException();
1204  }
1205  }
1206 
1207  final void checkForComodification() {
1208  if (expectedModCount != IntegerArrayList.this.modCount)
1209  throw new ConcurrentModificationException();
1210  }
1211  };
1212  }
1213 
1214  /* (non-Javadoc)
1215  * @see eu.mihosoft.vrl.v3d.ext.openjfx.importers.obj.IntegerArrayList#subList(int, int)
1216  */
1217  @Override public List<Integer> subList(int fromIndex, int toIndex) {
1218  subListRangeCheck(fromIndex, toIndex, size);
1219  return new IntegerArrayList.SubList(this, offset, fromIndex, toIndex);
1220  }
1221 
1227  private void rangeCheck(int index) {
1228  if (index < 0 || index >= this.size)
1229  throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
1230  }
1231 
1237  private void rangeCheckForAdd(int index) {
1238  if (index < 0 || index > this.size)
1239  throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
1240  }
1241 
1248  private String outOfBoundsMsg(int index) {
1249  return "Index: " + index + ", Size: " + this.size;
1250  }
1251 
1255  private void checkForComodification() {
1256  if (IntegerArrayList.this.modCount != this.modCount)
1257  throw new ConcurrentModificationException();
1258  }
1259  }
1260 }
boolean addAll(int index, Collection<? extends Integer > c)
boolean addAll(int index, Collection<? extends Integer > c)
boolean batchRemove(Collection<?> c, boolean complement)