gt:         for ( int i = _pos; i-- > 0; ) {
context: ///////////////////////////////////////////////////////////////////////////////
  // Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
  // Copyright (c) 2009, Rob Eden All Rights Reserved.
  // Copyright (c) 2009, Jeff Randall All Rights Reserved.
  //
  // This library is free software; you can redistribute it and/or
  // modify it under the terms of the GNU Lesser General Public
  // License as published by the Free Software Foundation; either
  // version 2.1 of the License, or (at your option) any later version.
  //
  // This library is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU Lesser General Public
  // License along with this program; if not, write to the Free Software
  // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  ///////////////////////////////////////////////////////////////////////////////
  
  package main.java.gnu.trove.list.array;
  
  
  import java.io.Externalizable;
  import java.io.IOException;
  import java.io.ObjectInput;
  import java.io.ObjectOutput;
  import java.util.*;
  
  import main.java.gnu.trove.TLongCollection;
  import main.java.gnu.trove.function.TLongFunction;
  import main.java.gnu.trove.impl.*;
  import main.java.gnu.trove.iterator.TLongIterator;
  import main.java.gnu.trove.list.TLongList;
  import main.java.gnu.trove.procedure.TLongProcedure;
  
  
  //////////////////////////////////////////////////
  // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
  //////////////////////////////////////////////////
  
  
  /**
   * A resizable, array-backed list of long primitives.
   */
  public class TLongArrayList implements TLongList, Externalizable {
  	static final long serialVersionUID = 1L;
  
      /** the data of the list */
      protected long[] _data;
  
      /** the index after the last entry in the list */
      protected int _pos;
  
      /** the default capacity for new lists */
      protected static final int DEFAULT_CAPACITY = Constants.DEFAULT_CAPACITY;
  
      /** the long value that represents null */
      protected long no_entry_value;
  
  
      /**
       * Creates a new <code>TLongArrayList</code> instance with the
       * default capacity.
       */
      @SuppressWarnings({"RedundantCast"})
      public TLongArrayList() {
          this( DEFAULT_CAPACITY, ( long ) 0 );
      }
  
  
      /**
       * Creates a new <code>TLongArrayList</code> instance with the
       * specified capacity.
       *
       * @param capacity an <code>int</code> value
       */
      @SuppressWarnings({"RedundantCast"})
      public TLongArrayList( int capacity ) {
          this( capacity, ( long ) 0 );
      }
  
  
      /**
       * Creates a new <code>TLongArrayList</code> instance with the
       * specified capacity.
       *
       * @param capacity an <code>int</code> value
       * @param no_entry_value an <code>long</code> value that represents null.
       */
      public TLongArrayList( int capacity, long no_entry_value ) {
          _data = new long[ capacity ];
          _pos = 0;
          this.no_entry_value = no_entry_value;
      }
  
      /**
       * Creates a new <code>TLongArrayList</code> instance that contains
       * a copy of the collection passed to us.
       *
       * @param collection the collection to copy
       */
      public TLongArrayList ( TLongCollection collection ) {
          this( collection.size() );
          addAll( collection ); 
      }
  
  
      /**
       * Creates a new <code>TLongArrayList</code> instance whose
       * capacity is the length of <tt>values</tt> array and whose
       * initial contents are the specified values.
       * <p>
       * A defensive copy of the given values is held by the new instance.
       *
       * @param values an <code>long[]</code> value
       */
      public TLongArrayList( long[] values ) {
          this( values.length );
          add( values );
      }
  
      protected TLongArrayList(long[] values, long no_entry_value, boolean wrap) {
          if (!wrap)
              throw new IllegalStateException("Wrong call");
  
          if (values == null)
              throw new IllegalArgumentException("values can not be null");
  
          _data = values;
          _pos = values.length;
          this.no_entry_value = no_entry_value;
      }
  
      /**
       * Returns a primitive List implementation that wraps around the given primitive array.
       * <p/>
       * NOTE: mutating operation are allowed as long as the List does not grow. In that case
       * an IllegalStateException will be thrown
       *
       * @param values
       * @return
       */
      public static TLongArrayList wrap(long[] values) {
          return wrap(values, ( long ) 0);
      }
  
      /**
       * Returns a primitive List implementation that wraps around the given primitive array.
       * <p/>
       * NOTE: mutating operation are allowed as long as the List does not grow. In that case
       * an IllegalStateException will be thrown
       *
       * @param values
       * @param no_entry_value
       * @return
       */
      public static TLongArrayList wrap(long[] values, long no_entry_value) {
          return new TLongArrayList(values, no_entry_value, true) {
              /**
               * Growing the wrapped external array is not allow
               */
              @Override
              public void ensureCapacity(int capacity) {
                  if (capacity > _data.length)
                      throw new IllegalStateException("Can not grow ArrayList wrapped external array");
              }
          };
      }
  
      /** {@inheritDoc} */
      public long getNoEntryValue() {
          return no_entry_value;
      }
  
  
      // sizing
  
      /**
       * Grow the internal array as needed to accommodate the specified number of elements.
       * The size of the array bytes on each resize unless capacity requires more than twice
       * the current capacity.
       */
      public void ensureCapacity( int capacity ) {
          if ( capacity > _data.length ) {
              int newCap = Math.max( _data.length << 1, capacity );
              long[] tmp = new long[ newCap ];
              System.arraycopy( _data, 0, tmp, 0, _data.length );
              _data = tmp;
          }
      }
  
  
      /** {@inheritDoc} */
      public int size() {
          return _pos;
      }
  
  
      /** {@inheritDoc} */
      public boolean isEmpty() {
          return _pos == 0;
      }
  
  
      /**
       * Sheds any excess capacity above and beyond the current size of the list.
       */
      public void trimToSize() {
          if ( _data.length > size() ) {
              long[] tmp = new long[ size() ];
              toArray( tmp, 0, tmp.length );
              _data = tmp;
          }
      }
  
  
      // modifying
  
      /** {@inheritDoc} */
      public boolean add( long val ) {
          ensureCapacity( _pos + 1 );
          _data[ _pos++ ] = val;
          return true;
      }
  
  
      /** {@inheritDoc} */
      public void add( long[] vals ) {
          add( vals, 0, vals.length );
      }
  
  
      /** {@inheritDoc} */
      public void add( long[] vals, int offset, int length ) {
          ensureCapacity( _pos + length );
          System.arraycopy( vals, offset, _data, _pos, length );
          _pos += length;
      }
  
  
      /** {@inheritDoc} */
      public void insert( int offset, long value ) {
          if ( offset == _pos ) {
              add( value );
              return;
          }
          ensureCapacity( _pos + 1 );
          // shift right
          System.arraycopy( _data, offset, _data, offset + 1, _pos - offset );
          // insert
          _data[ offset ] = value;
          _pos++;
      }
  
  
      /** {@inheritDoc} */
      public void insert( int offset, long[] values ) {
          insert( offset, values, 0, values.length );
      }
  
  
      /** {@inheritDoc} */
      public void insert( int offset, long[] values, int valOffset, int len ) {
          if ( offset == _pos ) {
              add( values, valOffset, len );
              return;
          }
  
          ensureCapacity( _pos + len );
          // shift right
          System.arraycopy( _data, offset, _data, offset + len, _pos - offset );
          // insert
          System.arraycopy( values, valOffset, _data, offset, len );
          _pos += len;
      }
  
  
      /** {@inheritDoc} */
      public long get( int offset ) {
          if ( offset >= _pos ) {
              throw new ArrayIndexOutOfBoundsException( offset );
          }
          return _data[ offset ];
      }
  
  
      /**
       * Returns the value at the specified offset without doing any bounds checking.
       */
      public long getQuick( int offset ) {
          return _data[ offset ];
      }
  
  
      /** {@inheritDoc} */
      public long set( int offset, long val ) {
          if ( offset >= _pos ) {
              throw new ArrayIndexOutOfBoundsException( offset );
          }
  
  		long prev_val = _data[ offset ];
          _data[ offset ] = val;
  		return prev_val;
      }
  
  
      /** {@inheritDoc} */
      public long replace( int offset, long val ) {
          if ( offset >= _pos ) {
              throw new ArrayIndexOutOfBoundsException( offset );
          }
          long old = _data[ offset ];
          _data[ offset ] = val;
          return old;
      }
  
  
      /** {@inheritDoc} */
      public void set( int offset, long[] values ) {
          set( offset, values, 0, values.length );
      }
  
  
      /** {@inheritDoc} */
      public void set( int offset, long[] values, int valOffset, int length ) {
          if ( offset < 0 || offset + length > _pos ) {
              throw new ArrayIndexOutOfBoundsException( offset );
          }
          System.arraycopy( values, valOffset, _data, offset, length );
      }
  
  
      /**
       * Sets the value at the specified offset without doing any bounds checking.
       */
      public void setQuick( int offset, long val ) {
          _data[ offset ] = val;
      }
  
  
      /** {@inheritDoc} */
      public void clear() {
          clear( DEFAULT_CAPACITY );
      }
  
  
      /**
       * Flushes the internal state of the list, setting the capacity of the empty list to
       * <tt>capacity</tt>.
       */
      public void clear( int capacity ) {
          _data = new long[ capacity ];
          _pos = 0;
      }
  
  
      /**
       * Sets the size of the list to 0, but does not change its capacity. This method can
       * be used as an alternative to the {@link #clear()} method if you want to recycle a
       * list without allocating new backing arrays.
       */
      public void reset() {
          _pos = 0;
          Arrays.fill( _data, no_entry_value );
      }
  
  
      /**
       * Sets the size of the list to 0, but does not change its capacity. This method can
       * be used as an alternative to the {@link #clear()} method if you want to recycle a
       * list without allocating new backing arrays. This method differs from
       * {@link #reset()} in that it does not clear the old values in the backing array.
       * Thus, it is possible for getQuick to return stale data if this method is used and
       * the caller is careless about bounds checking.
       */
      public void resetQuick() {
          _pos = 0;
      }
  
  
      /** {@inheritDoc} */
      public boolean remove( long value ) {
          for ( int index = 0; index < _pos; index++ ) {
              if ( value == _data[index]  ) {
                  remove( index, 1 );
                  return true;
              }
          }
          return false;
      }
  
  
      /** {@inheritDoc} */
      public long removeAt( int offset ) {
          long old = get( offset );
          remove( offset, 1 );
          return old;
      }
  
  
      /** {@inheritDoc} */
      public void remove( int offset, int length ) {
  		if ( length == 0 ) return;
          if ( offset < 0 || offset >= _pos ) {
              throw new ArrayIndexOutOfBoundsException(offset);
          }
  
          if ( offset == 0 ) {
              // data at the front
              System.arraycopy( _data, length, _data, 0, _pos - length );
          }
          else if ( _pos - length == offset ) {
              // no copy to make, decrementing pos "deletes" values at
              // the end
          }
          else {
              // data in the middle
              System.arraycopy( _data, offset + length, _data, offset,
                  _pos - ( offset + length ) );
          }
          _pos -= length;
          // no need to clear old values beyond _pos, because this is a
          // primitive collection and 0 takes as much room as any other
          // value
      }
  
  
      /** {@inheritDoc} */
      public TLongIterator iterator() {
          return new TLongArrayIterator( 0 );
      }
  
  
      /** {@inheritDoc} */
      public boolean containsAll( Collection<?> collection ) {
          for ( Object element : collection ) {
              if ( element instanceof Long ) {
                  long c = ( ( Long ) element ).longValue();
                  if ( ! contains( c ) ) {
                      return false;
                  }
              } else {
                  return false;
              }
  
          }
          return true;
      }
  
  
      /** {@inheritDoc} */
      public boolean containsAll( TLongCollection collection ) {
          if ( this == collection ) {
              return true;
          }
          TLongIterator iter = collection.iterator();
          while ( iter.hasNext() ) {
              long element = iter.next();
              if ( ! contains( element ) ) {
                  return false;
              }
          }
          return true;
      }
  
  
      /** {@inheritDoc} */
      public boolean containsAll( long[] array ) {
          for ( int i = array.length; i-- > 0; ) {
              if ( ! contains( array[i] ) ) {
                  return false;
              }
          }
          return true;
      }
  
  
      /** {@inheritDoc} */
      public boolean addAll( Collection<? extends Long> collection ) {
          boolean changed = false;
          for ( Long element : collection ) {
              long e = element.longValue();
              if ( add( e ) ) {
                  changed = true;
              }
          }
          return changed;
      }
  
  
      /** {@inheritDoc} */
      public boolean addAll( TLongCollection collection ) {
          boolean changed = false;
          TLongIterator iter = collection.iterator();
          while ( iter.hasNext() ) {
              long element = iter.next();
              if ( add( element ) ) {
                  changed = true;
              }
          }
          return changed;
      }
  
  
      /** {@inheritDoc} */
      public boolean addAll( long[] array ) {
          boolean changed = false;
          for ( long element : array ) {
              if ( add( element ) ) {
                  changed = true;
              }
          }
          return changed;
      }
  
  
      /** {@inheritDoc} */
      @SuppressWarnings({"SuspiciousMethodCalls"})
      public boolean retainAll( Collection<?> collection ) {
          boolean modified = false;
  	    TLongIterator iter = iterator();
  	    while ( iter.hasNext() ) {
  	        if ( ! collection.contains( Long.valueOf ( iter.next() ) ) ) {
  		        iter.remove();
  		        modified = true;
  	        }
  	    }
  	    return modified;
      }
  
  
      /** {@inheritDoc} */
      public boolean retainAll( TLongCollection collection ) {
          if ( this == collection ) {
              return false;
          }
          boolean modified = false;
  	    TLongIterator iter = iterator();
  	    while ( iter.hasNext() ) {
  	        if ( ! collection.contains( iter.next() ) ) {
  		        iter.remove();
  		        modified = true;
  	        }
  	    }
  	    return modified;
      }
  
  
      /** {@inheritDoc} */
      public boolean retainAll( long[] array ) {
          boolean changed = false;
          Arrays.sort( array );
          long[] data = _data;
  
  