/** {@inheritDoc} */ public boolean addAll( short[] array ) { boolean changed = false; for ( short element : array ) { if ( add( element ) ) { changed = true; } } return changed; }
/** * Pushes the value onto the top of the stack. * * @param val an <code>short</code> value */ public void push( short val ) { _list.add( val ); }
/** * Creates a new <code>TShortArrayList</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>short[]</code> value */ public TShortArrayList( short[] values ) { this( values.length ); add( values ); }
/** {@inheritDoc} */ public void add( short[] vals ) { add( vals, 0, vals.length ); }
/** {@inheritDoc} */ public boolean addAll( Collection<? extends Short> collection ) { boolean changed = false; for ( Short element : collection ) { short e = element.shortValue(); if ( add( e ) ) { changed = true; } } return changed; }
/** {@inheritDoc} */ public void insert( int offset, short[] 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 void insert( int offset, short 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 TShortList subList( int begin, int end ) { if ( end < begin ) { throw new IllegalArgumentException( "end index " + end + " greater than begin index " + begin ); } if ( begin < 0 ) { throw new IndexOutOfBoundsException( "begin index can not be < 0" ); } if ( end > _data.length ) { throw new IndexOutOfBoundsException( "end index < " + _data.length ); } TShortArrayList list = new TShortArrayList( end - begin ); for ( int i = begin; i < end; i++ ) { list.add( _data[ i ] ); } return list; }
/** {@inheritDoc} */ public TShortList grep( TShortProcedure condition ) { TShortArrayList list = new TShortArrayList(); for ( int i = 0; i < _pos; i++ ) { if ( condition.execute( _data[ i ] ) ) { list.add( _data[ i ] ); } } return list; }
/** {@inheritDoc} */ public TShortList inverseGrep( TShortProcedure condition ) { TShortArrayList list = new TShortArrayList(); for ( int i = 0; i < _pos; i++ ) { if ( !condition.execute( _data[ i ] ) ) { list.add( _data[ i ] ); } } return list; }
/** {@inheritDoc} */ public boolean addAll( TShortCollection collection ) { boolean changed = false; TShortIterator iter = collection.iterator(); while ( iter.hasNext() ) { short element = iter.next(); if ( add( element ) ) { changed = true; } } return changed; }
/** {@inheritDoc} */ public boolean addAll( short[] array ) { boolean changed = false; for ( short element : array ) { if ( add( element ) ) { changed = true; } } return changed; }
/** * Pushes the value onto the top of the stack. * * @param val an <code>short</code> value */ public void push( short val ) { _list.add( val ); }
/** * Pushes the value onto the top of the stack. * * @param val an <code>short</code> value */ @Override public void push( short val ) { _list.add( val ); }
/** {@inheritDoc} */ public boolean addAll( Collection<? extends Short> collection ) { boolean changed = false; for ( Short element : collection ) { short e = element.shortValue(); if ( add( e ) ) { changed = true; } } return changed; }
/** * Extract the second values from a list of pairs. * * @param data the data * @return extracted second values */ public static gnu.trove.list.array.TShortArrayList getSecond(Iterable<IntShortPair> data) { gnu.trove.list.array.TShortArrayList extracted = new gnu.trove.list.array.TShortArrayList(); for (IntShortPair item : data) extracted.add(item.second); return extracted; }
/** * Extract the first values from a list of pairs. * * @param data the data * @return extracted first values */ public static gnu.trove.list.array.TShortArrayList getFirst(Iterable<ShortBytePair> data) { gnu.trove.list.array.TShortArrayList extracted = new gnu.trove.list.array.TShortArrayList(); for (ShortBytePair item : data) extracted.add(item.first); return extracted; }
/** {@inheritDoc} */ public TShortList grep( TShortProcedure condition ) { TShortArrayList list = new TShortArrayList(); for ( int i = 0; i < _pos; i++ ) { if ( condition.execute( _data[ i ] ) ) { list.add( _data[ i ] ); } } return list; }
/** {@inheritDoc} */ public TShortList inverseGrep( TShortProcedure condition ) { TShortArrayList list = new TShortArrayList(); for ( int i = 0; i < _pos; i++ ) { if ( !condition.execute( _data[ i ] ) ) { list.add( _data[ i ] ); } } return list; }
/** {@inheritDoc} */ public boolean addAll( TShortCollection collection ) { boolean changed = false; TShortIterator iter = collection.iterator(); while ( iter.hasNext() ) { short element = iter.next(); if ( add( element ) ) { changed = true; } } return changed; }