1 ///////////////////////////////////////////////////////////////////////////////
\r
2 // Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
\r
3 // Copyright (c) 2009, Rob Eden All Rights Reserved.
\r
4 // Copyright (c) 2009, Jeff Randall All Rights Reserved.
\r
6 // This library is free software; you can redistribute it and/or
\r
7 // modify it under the terms of the GNU Lesser General Public
\r
8 // License as published by the Free Software Foundation; either
\r
9 // version 2.1 of the License, or (at your option) any later version.
\r
11 // This library is distributed in the hope that it will be useful,
\r
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 // GNU General Public License for more details.
\r
16 // You should have received a copy of the GNU Lesser General Public
\r
17 // License along with this program; if not, write to the Free Software
\r
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
19 ///////////////////////////////////////////////////////////////////////////////
\r
21 package org.simantics.db.impl.graph;
\r
23 import gnu.trove.TIntCollection;
\r
24 import gnu.trove.function.TIntFunction;
\r
25 import gnu.trove.impl.Constants;
\r
26 import gnu.trove.impl.HashFunctions;
\r
27 import gnu.trove.iterator.TIntIterator;
\r
28 import gnu.trove.procedure.TIntProcedure;
\r
30 import java.io.IOException;
\r
31 import java.io.ObjectInput;
\r
32 import java.io.ObjectOutput;
\r
33 import java.util.Arrays;
\r
34 import java.util.Collection;
\r
35 import java.util.ConcurrentModificationException;
\r
36 import java.util.NoSuchElementException;
\r
37 import java.util.Random;
\r
40 //////////////////////////////////////////////////
\r
41 // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
\r
42 //////////////////////////////////////////////////
\r
46 * A resizable, array-backed list of int primitives.
\r
48 public class TIntArrayListInternal {
\r
50 /** the data of the list */
\r
51 protected int[] _data;
\r
53 /** the index after the last entry in the list */
\r
56 /** the default capacity for new lists */
\r
57 protected static final int DEFAULT_CAPACITY = Constants.DEFAULT_CAPACITY;
\r
59 /** the int value that represents null */
\r
60 protected int no_entry_value;
\r
64 * Creates a new <code>TIntArrayList</code> instance with the
\r
67 @SuppressWarnings({"RedundantCast"})
\r
68 public TIntArrayListInternal() {
\r
69 this( DEFAULT_CAPACITY, ( int ) 0 );
\r
74 * Creates a new <code>TIntArrayList</code> instance with the
\r
75 * specified capacity.
\r
77 * @param capacity an <code>int</code> value
\r
79 @SuppressWarnings({"RedundantCast"})
\r
80 public TIntArrayListInternal( int capacity ) {
\r
81 this( capacity, ( int ) 0 );
\r
86 * Creates a new <code>TIntArrayList</code> instance with the
\r
87 * specified capacity.
\r
89 * @param capacity an <code>int</code> value
\r
90 * @param no_entry_value an <code>int</code> value that represents null.
\r
92 public TIntArrayListInternal( int capacity, int no_entry_value ) {
\r
93 _data = new int[ capacity ];
\r
95 this.no_entry_value = no_entry_value;
\r
99 * Creates a new <code>TIntArrayList</code> instance that contains
\r
100 * a copy of the collection passed to us.
\r
102 * @param collection the collection to copy
\r
104 public TIntArrayListInternal ( TIntCollection collection ) {
\r
105 this( collection.size() );
\r
106 addAll( collection );
\r
111 * Creates a new <code>TIntArrayList</code> instance whose
\r
112 * capacity is the length of <tt>values</tt> array and whose
\r
113 * initial contents are the specified values.
\r
115 * A defensive copy of the given values is held by the new instance.
\r
117 * @param values an <code>int[]</code> value
\r
119 public TIntArrayListInternal( int[] values ) {
\r
120 this( values.length );
\r
124 protected TIntArrayListInternal(int[] values, int no_entry_value, boolean wrap) {
\r
126 throw new IllegalStateException("Wrong call");
\r
128 if (values == null)
\r
129 throw new IllegalArgumentException("values can not be null");
\r
132 _pos = values.length;
\r
133 this.no_entry_value = no_entry_value;
\r
137 * Returns a primitive List implementation that wraps around the given primitive array.
\r
139 * NOTE: mutating operation are allowed as long as the List does not grow. In that case
\r
140 * an IllegalStateException will be thrown
\r
145 public static TIntArrayListInternal wrap(int[] values) {
\r
146 return wrap(values, ( int ) 0);
\r
150 * Returns a primitive List implementation that wraps around the given primitive array.
\r
152 * NOTE: mutating operation are allowed as long as the List does not grow. In that case
\r
153 * an IllegalStateException will be thrown
\r
156 * @param no_entry_value
\r
159 public static TIntArrayListInternal wrap(int[] values, int no_entry_value) {
\r
160 return new TIntArrayListInternal(values, no_entry_value, true) {
\r
162 * Growing the wrapped external array is not allow
\r
165 public void ensureCapacity(int capacity) {
\r
166 if (capacity > _data.length)
\r
167 throw new IllegalStateException("Can not grow ArrayList wrapped external array");
\r
172 /** {@inheritDoc} */
\r
173 public int getNoEntryValue() {
\r
174 return no_entry_value;
\r
181 * Grow the internal array as needed to accommodate the specified number of elements.
\r
182 * The size of the array bytes on each resize unless capacity requires more than twice
\r
183 * the current capacity.
\r
185 public void ensureCapacity( int capacity ) {
\r
186 if ( capacity > _data.length ) {
\r
187 int newCap = Math.max( _data.length << 1, capacity );
\r
188 int[] tmp = new int[ newCap ];
\r
189 System.arraycopy( _data, 0, tmp, 0, _data.length );
\r
195 /** {@inheritDoc} */
\r
196 public int sizeInternal() {
\r
201 /** {@inheritDoc} */
\r
202 public boolean isEmpty() {
\r
208 * Sheds any excess capacity above and beyond the current size of the list.
\r
210 public void trimToSize() {
\r
211 if ( _data.length > sizeInternal() ) {
\r
212 int[] tmp = new int[ sizeInternal() ];
\r
213 toArray( tmp, 0, tmp.length );
\r
221 /** {@inheritDoc} */
\r
222 public boolean add( int val ) {
\r
223 ensureCapacity( _pos + 1 );
\r
224 _data[ _pos++ ] = val;
\r
229 /** {@inheritDoc} */
\r
230 public void add( int[] vals ) {
\r
231 add( vals, 0, vals.length );
\r
235 /** {@inheritDoc} */
\r
236 public void add( int[] vals, int offset, int length ) {
\r
237 ensureCapacity( _pos + length );
\r
238 System.arraycopy( vals, offset, _data, _pos, length );
\r
243 /** {@inheritDoc} */
\r
244 public void insert( int offset, int value ) {
\r
245 if ( offset == _pos ) {
\r
249 ensureCapacity( _pos + 1 );
\r
251 System.arraycopy( _data, offset, _data, offset + 1, _pos - offset );
\r
253 _data[ offset ] = value;
\r
258 /** {@inheritDoc} */
\r
259 public void insert( int offset, int[] values ) {
\r
260 insert( offset, values, 0, values.length );
\r
264 /** {@inheritDoc} */
\r
265 public void insert( int offset, int[] values, int valOffset, int len ) {
\r
266 if ( offset == _pos ) {
\r
267 add( values, valOffset, len );
\r
271 ensureCapacity( _pos + len );
\r
273 System.arraycopy( _data, offset, _data, offset + len, _pos - offset );
\r
275 System.arraycopy( values, valOffset, _data, offset, len );
\r
280 /** {@inheritDoc} */
\r
281 public int getAt( int offset ) {
\r
282 if ( offset >= _pos ) {
\r
283 throw new ArrayIndexOutOfBoundsException( offset );
\r
285 return _data[ offset ];
\r
290 * Returns the value at the specified offset without doing any bounds checking.
\r
292 public int getQuick( int offset ) {
\r
293 return _data[ offset ];
\r
297 /** {@inheritDoc} */
\r
298 public int set( int offset, int val ) {
\r
299 if ( offset >= _pos ) {
\r
300 throw new ArrayIndexOutOfBoundsException( offset );
\r
303 int prev_val = _data[ offset ];
\r
304 _data[ offset ] = val;
\r
309 /** {@inheritDoc} */
\r
310 public int replace( int offset, int val ) {
\r
311 if ( offset >= _pos ) {
\r
312 throw new ArrayIndexOutOfBoundsException( offset );
\r
314 int old = _data[ offset ];
\r
315 _data[ offset ] = val;
\r
320 /** {@inheritDoc} */
\r
321 public void set( int offset, int[] values ) {
\r
322 set( offset, values, 0, values.length );
\r
326 /** {@inheritDoc} */
\r
327 public void set( int offset, int[] values, int valOffset, int length ) {
\r
328 if ( offset < 0 || offset + length > _pos ) {
\r
329 throw new ArrayIndexOutOfBoundsException( offset );
\r
331 System.arraycopy( values, valOffset, _data, offset, length );
\r
336 * Sets the value at the specified offset without doing any bounds checking.
\r
338 public void setQuick( int offset, int val ) {
\r
339 _data[ offset ] = val;
\r
343 /** {@inheritDoc} */
\r
344 public void clear() {
\r
345 clear( DEFAULT_CAPACITY );
\r
350 * Flushes the internal state of the list, setting the capacity of the empty list to
\r
351 * <tt>capacity</tt>.
\r
353 public void clear( int capacity ) {
\r
354 _data = new int[ capacity ];
\r
360 * Sets the size of the list to 0, but does not change its capacity. This method can
\r
361 * be used as an alternative to the {@link #clear()} method if you want to recycle a
\r
362 * list without allocating new backing arrays.
\r
364 public void reset() {
\r
366 Arrays.fill( _data, no_entry_value );
\r
371 * Sets the size of the list to 0, but does not change its capacity. This method can
\r
372 * be used as an alternative to the {@link #clear()} method if you want to recycle a
\r
373 * list without allocating new backing arrays. This method differs from
\r
374 * {@link #reset()} in that it does not clear the old values in the backing array.
\r
375 * Thus, it is possible for getQuick to return stale data if this method is used and
\r
376 * the caller is careless about bounds checking.
\r
378 public void resetQuick() {
\r
383 /** {@inheritDoc} */
\r
384 public boolean removeValue( int value ) {
\r
385 for ( int index = 0; index < _pos; index++ ) {
\r
386 if ( value == _data[index] ) {
\r
387 remove( index, 1 );
\r
395 /** {@inheritDoc} */
\r
396 public int removeAt( int offset ) {
\r
397 int old = getAt( offset );
\r
398 remove( offset, 1 );
\r
403 /** {@inheritDoc} */
\r
404 public void remove( int offset, int length ) {
\r
405 if ( length == 0 ) return;
\r
406 if ( offset < 0 || offset >= _pos ) {
\r
407 throw new ArrayIndexOutOfBoundsException(offset);
\r
410 if ( offset == 0 ) {
\r
411 // data at the front
\r
412 System.arraycopy( _data, length, _data, 0, _pos - length );
\r
414 else if ( _pos - length == offset ) {
\r
415 // no copy to make, decrementing pos "deletes" values at
\r
419 // data in the middle
\r
420 System.arraycopy( _data, offset + length, _data, offset,
\r
421 _pos - ( offset + length ) );
\r
424 // no need to clear old values beyond _pos, because this is a
\r
425 // primitive collection and 0 takes as much room as any other
\r
430 /** {@inheritDoc} */
\r
431 public TIntIterator iteratorInternal() {
\r
432 return new TIntArrayIterator( 0 );
\r
436 /** {@inheritDoc} */
\r
437 public boolean containsAll( Collection<?> collection ) {
\r
438 for ( Object element : collection ) {
\r
439 if ( element instanceof Integer ) {
\r
440 int c = ( ( Integer ) element ).intValue();
\r
441 if ( ! contains( c ) ) {
\r
453 /** {@inheritDoc} */
\r
454 public boolean containsAll( TIntCollection collection ) {
\r
455 if ( this == collection ) {
\r
458 TIntIterator iter = collection.iterator();
\r
459 while ( iter.hasNext() ) {
\r
460 int element = iter.next();
\r
461 if ( ! contains( element ) ) {
\r
469 /** {@inheritDoc} */
\r
470 public boolean containsAll( int[] array ) {
\r
471 for ( int i = array.length; i-- > 0; ) {
\r
472 if ( ! contains( array[i] ) ) {
\r
480 // /** {@inheritDoc} */
\r
481 // public boolean addAll( Collection<? extends Integer> collection ) {
\r
482 // boolean changed = false;
\r
483 // for ( Integer element : collection ) {
\r
484 // int e = element.intValue();
\r
485 // if ( add( e ) ) {
\r
493 /** {@inheritDoc} */
\r
494 public boolean addAll( TIntCollection collection ) {
\r
495 boolean changed = false;
\r
496 TIntIterator iter = collection.iterator();
\r
497 while ( iter.hasNext() ) {
\r
498 int element = iter.next();
\r
499 if ( add( element ) ) {
\r
507 /** {@inheritDoc} */
\r
508 public boolean addAll( int[] array ) {
\r
509 boolean changed = false;
\r
510 for ( int element : array ) {
\r
511 if ( add( element ) ) {
\r
519 /** {@inheritDoc} */
\r
520 @SuppressWarnings({"SuspiciousMethodCalls"})
\r
521 public boolean retainAll( Collection<?> collection ) {
\r
522 boolean modified = false;
\r
523 TIntIterator iter = iteratorInternal();
\r
524 while ( iter.hasNext() ) {
\r
525 if ( ! collection.contains( Integer.valueOf ( iter.next() ) ) ) {
\r
534 /** {@inheritDoc} */
\r
535 public boolean retainAll( TIntCollection collection ) {
\r
536 if ( this == collection ) {
\r
539 boolean modified = false;
\r
540 TIntIterator iter = iteratorInternal();
\r
541 while ( iter.hasNext() ) {
\r
542 if ( ! collection.contains( iter.next() ) ) {
\r
551 /** {@inheritDoc} */
\r
552 public boolean retainAll( int[] array ) {
\r
553 boolean changed = false;
\r
554 Arrays.sort( array );
\r
555 int[] data = _data;
\r
557 for ( int i = _pos; i-- > 0; ) {
\r
558 if ( Arrays.binarySearch( array, data[i] ) < 0 ) {
\r
567 /** {@inheritDoc} */
\r
568 public boolean removeAll( Collection<?> collection ) {
\r
569 boolean changed = false;
\r
570 for ( Object element : collection ) {
\r
571 if ( element instanceof Integer ) {
\r
572 int c = ( ( Integer ) element ).intValue();
\r
573 if ( removeValue( c ) ) {
\r
582 /** {@inheritDoc} */
\r
583 public boolean removeAll( TIntCollection collection ) {
\r
584 if ( collection == this ) {
\r
588 boolean changed = false;
\r
589 TIntIterator iter = collection.iterator();
\r
590 while ( iter.hasNext() ) {
\r
591 int element = iter.next();
\r
592 if ( removeValue( element ) ) {
\r
600 /** {@inheritDoc} */
\r
601 public boolean removeAll( int[] array ) {
\r
602 boolean changed = false;
\r
603 for ( int i = array.length; i-- > 0; ) {
\r
604 if ( removeValue(array[i]) ) {
\r
612 /** {@inheritDoc} */
\r
613 public void transformValues( TIntFunction function ) {
\r
614 for ( int i = _pos; i-- > 0; ) {
\r
615 _data[ i ] = function.execute( _data[ i ] );
\r
620 /** {@inheritDoc} */
\r
621 public void reverse() {
\r
622 reverse( 0, _pos );
\r
626 /** {@inheritDoc} */
\r
627 public void reverse( int from, int to ) {
\r
628 if ( from == to ) {
\r
629 return; // nothing to do
\r
632 throw new IllegalArgumentException( "from cannot be greater than to" );
\r
634 for ( int i = from, j = to - 1; i < j; i++, j-- ) {
\r
640 /** {@inheritDoc} */
\r
641 public void shuffle( Random rand ) {
\r
642 for ( int i = _pos; i-- > 1; ) {
\r
643 swap( i, rand.nextInt( i ) );
\r
649 * Swap the values at offsets <tt>i</tt> and <tt>j</tt>.
\r
651 * @param i an offset into the data array
\r
652 * @param j an offset into the data array
\r
654 private void swap( int i, int j ) {
\r
655 int tmp = _data[ i ];
\r
656 _data[ i ] = _data[ j ];
\r
663 // /** {@inheritDoc} */
\r
664 // public TIntList subList( int begin, int end ) {
\r
665 // if ( end < begin ) {
\r
666 // throw new IllegalArgumentException( "end index " + end +
\r
667 // " greater than begin index " + begin );
\r
669 // if ( begin < 0 ) {
\r
670 // throw new IndexOutOfBoundsException( "begin index can not be < 0" );
\r
672 // if ( end > _data.length ) {
\r
673 // throw new IndexOutOfBoundsException( "end index < " + _data.length );
\r
675 // TIntArrayListInternal list = new TIntArrayListInternal( end - begin );
\r
676 // for ( int i = begin; i < end; i++ ) {
\r
677 // list.add( _data[ i ] );
\r
683 /** {@inheritDoc} */
\r
684 public int[] toArrayInternal() {
\r
685 return toArray( 0, _pos );
\r
689 /** {@inheritDoc} */
\r
690 public int[] toArray( int offset, int len ) {
\r
691 int[] rv = new int[ len ];
\r
692 toArray( rv, offset, len );
\r
697 /** {@inheritDoc} */
\r
698 public int[] toArray( int[] dest ) {
\r
699 int len = dest.length;
\r
700 if ( dest.length > _pos ) {
\r
702 dest[len] = no_entry_value;
\r
704 toArray( dest, 0, len );
\r
709 /** {@inheritDoc} */
\r
710 public int[] toArray( int[] dest, int offset, int len ) {
\r
712 return dest; // nothing to copy
\r
714 if ( offset < 0 || offset >= _pos ) {
\r
715 throw new ArrayIndexOutOfBoundsException( offset );
\r
717 System.arraycopy( _data, offset, dest, 0, len );
\r
722 /** {@inheritDoc} */
\r
723 public int[] toArray( int[] dest, int source_pos, int dest_pos, int len ) {
\r
725 return dest; // nothing to copy
\r
727 if ( source_pos < 0 || source_pos >= _pos ) {
\r
728 throw new ArrayIndexOutOfBoundsException( source_pos );
\r
730 System.arraycopy( _data, source_pos, dest, dest_pos, len );
\r
737 /** {@inheritDoc} */
\r
739 public boolean equals( Object other ) {
\r
740 if ( other == this ) {
\r
743 else if ( other instanceof TIntArrayListInternal ) {
\r
744 TIntArrayListInternal that = ( TIntArrayListInternal )other;
\r
745 if ( that.sizeInternal() != this.sizeInternal() ) return false;
\r
747 for ( int i = _pos; i-- > 0; ) {
\r
748 if ( this._data[ i ] != that._data[ i ] ) {
\r
759 /** {@inheritDoc} */
\r
761 public int hashCode() {
\r
763 for ( int i = _pos; i-- > 0; ) {
\r
764 h += HashFunctions.hash( _data[ i ] );
\r
772 /** {@inheritDoc} */
\r
773 public boolean forEach( TIntProcedure procedure ) {
\r
774 for ( int i = 0; i < _pos; i++ ) {
\r
775 if ( !procedure.execute( _data[ i ] ) ) {
\r
783 /** {@inheritDoc} */
\r
784 public boolean forEachDescending( TIntProcedure procedure ) {
\r
785 for ( int i = _pos; i-- > 0; ) {
\r
786 if ( !procedure.execute( _data[ i ] ) ) {
\r
796 /** {@inheritDoc} */
\r
797 public void sort() {
\r
798 Arrays.sort( _data, 0, _pos );
\r
802 /** {@inheritDoc} */
\r
803 public void sort( int fromIndex, int toIndex ) {
\r
804 Arrays.sort( _data, fromIndex, toIndex );
\r
810 /** {@inheritDoc} */
\r
811 public void fill( int val ) {
\r
812 Arrays.fill( _data, 0, _pos, val );
\r
816 /** {@inheritDoc} */
\r
817 public void fill( int fromIndex, int toIndex, int val ) {
\r
818 if ( toIndex > _pos ) {
\r
819 ensureCapacity( toIndex );
\r
822 Arrays.fill( _data, fromIndex, toIndex, val );
\r
828 /** {@inheritDoc} */
\r
829 public int binarySearch( int value ) {
\r
830 return binarySearch( value, 0, _pos );
\r
834 /** {@inheritDoc} */
\r
835 public int binarySearch(int value, int fromIndex, int toIndex) {
\r
836 if ( fromIndex < 0 ) {
\r
837 throw new ArrayIndexOutOfBoundsException( fromIndex );
\r
839 if ( toIndex > _pos ) {
\r
840 throw new ArrayIndexOutOfBoundsException( toIndex );
\r
843 int low = fromIndex;
\r
844 int high = toIndex - 1;
\r
846 while ( low <= high ) {
\r
847 int mid = ( low + high ) >>> 1;
\r
848 int midVal = _data[ mid ];
\r
850 if ( midVal < value ) {
\r
853 else if ( midVal > value ) {
\r
857 return mid; // value found
\r
860 return -( low + 1 ); // value not found.
\r
864 /** {@inheritDoc} */
\r
865 public int indexOf( int value ) {
\r
866 return indexOf( 0, value );
\r
870 /** {@inheritDoc} */
\r
871 public int indexOf( int offset, int value ) {
\r
872 for ( int i = offset; i < _pos; i++ ) {
\r
873 if ( _data[ i ] == value ) {
\r
881 /** {@inheritDoc} */
\r
882 public int lastIndexOf( int value ) {
\r
883 return lastIndexOf( _pos, value );
\r
887 /** {@inheritDoc} */
\r
888 public int lastIndexOf( int offset, int value ) {
\r
889 for ( int i = offset; i-- > 0; ) {
\r
890 if ( _data[ i ] == value ) {
\r
898 /** {@inheritDoc} */
\r
899 public boolean contains( int value ) {
\r
900 return lastIndexOf( value ) >= 0;
\r
904 // /** {@inheritDoc} */
\r
905 // public TIntList grep( TIntProcedure condition ) {
\r
906 // TIntArrayListInternal list = new TIntArrayListInternal();
\r
907 // for ( int i = 0; i < _pos; i++ ) {
\r
908 // if ( condition.execute( _data[ i ] ) ) {
\r
909 // list.add( _data[ i ] );
\r
916 // /** {@inheritDoc} */
\r
917 // public TIntList inverseGrep( TIntProcedure condition ) {
\r
918 // TIntArrayListInternal list = new TIntArrayListInternal();
\r
919 // for ( int i = 0; i < _pos; i++ ) {
\r
920 // if ( !condition.execute( _data[ i ] ) ) {
\r
921 // list.add( _data[ i ] );
\r
928 /** {@inheritDoc} */
\r
930 if ( sizeInternal() == 0 ) {
\r
931 throw new IllegalStateException("cannot find maximum of an empty list");
\r
933 int max = Integer.MIN_VALUE;
\r
934 for ( int i = 0; i < _pos; i++ ) {
\r
935 if ( _data[ i ] > max ) {
\r
943 /** {@inheritDoc} */
\r
945 if ( sizeInternal() == 0 ) {
\r
946 throw new IllegalStateException( "cannot find minimum of an empty list" );
\r
948 int min = Integer.MAX_VALUE;
\r
949 for ( int i = 0; i < _pos; i++ ) {
\r
950 if ( _data[i] < min ) {
\r
958 /** {@inheritDoc} */
\r
961 for ( int i = 0; i < _pos; i++ ) {
\r
970 /** {@inheritDoc} */
\r
972 public String toString() {
\r
973 final StringBuilder buf = new StringBuilder( "{" );
\r
974 for ( int i = 0, end = _pos - 1; i < end; i++ ) {
\r
975 buf.append( _data[ i ] );
\r
976 buf.append( ", " );
\r
978 if ( sizeInternal() > 0 ) {
\r
979 buf.append( _data[ _pos - 1 ] );
\r
982 return buf.toString();
\r
986 /** TIntArrayList iterator */
\r
987 class TIntArrayIterator implements TIntIterator {
\r
989 /** Index of element to be returned by subsequent call to next. */
\r
990 private int cursor = 0;
\r
993 * Index of element returned by most recent call to next or
\r
994 * previous. Reset to -1 if this element is deleted by a call
\r
1000 TIntArrayIterator( int index ) {
\r
1005 /** {@inheritDoc} */
\r
1006 public boolean hasNext() {
\r
1007 return cursor < sizeInternal();
\r
1011 /** {@inheritDoc} */
\r
1012 public int next() {
\r
1014 int next = getAt( cursor );
\r
1015 lastRet = cursor++;
\r
1017 } catch ( IndexOutOfBoundsException e ) {
\r
1018 throw new NoSuchElementException();
\r
1023 /** {@inheritDoc} */
\r
1024 public void remove() {
\r
1025 if ( lastRet == -1 )
\r
1026 throw new IllegalStateException();
\r
1029 TIntArrayListInternal.this.remove( lastRet, 1);
\r
1030 if ( lastRet < cursor )
\r
1033 } catch ( IndexOutOfBoundsException e ) {
\r
1034 throw new ConcurrentModificationException();
\r
1040 public void writeExternal( ObjectOutput out ) throws IOException {
\r
1042 out.writeByte( 0 );
\r
1045 out.writeInt( _pos );
\r
1048 out.writeInt( no_entry_value );
\r
1051 int len = _data.length;
\r
1052 out.writeInt( len );
\r
1053 for( int i = 0; i < len; i++ ) {
\r
1054 out.writeInt( _data[ i ] );
\r
1059 public void readExternal( ObjectInput in )
\r
1060 throws IOException, ClassNotFoundException {
\r
1066 _pos = in.readInt();
\r
1069 no_entry_value = in.readInt();
\r
1072 int len = in.readInt();
\r
1073 _data = new int[ len ];
\r
1074 for( int i = 0; i < len; i++ ) {
\r
1075 _data[ i ] = in.readInt();
\r
1078 } // TIntArrayList
\r