/** * Returns the current depth of the stack. */ public int size() { return _list.size(); }
/** {@inheritDoc} */ public boolean hasNext() { return cursor < size(); }
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( other == this ) { return true; } else if ( other instanceof TShortArrayList ) { TShortArrayList that = ( TShortArrayList )other; if ( that.size() != this.size() ) return false; else { for ( int i = _pos; i-- > 0; ) { if ( this._data[ i ] != that._data[ i ] ) { return false; } } return true; } } else return false; }
/** {@inheritDoc} */ public short min() { if ( size() == 0 ) { throw new IllegalStateException( "cannot find minimum of an empty list" ); } short min = Short.MAX_VALUE; for ( int i = 0; i < _pos; i++ ) { if ( _data[i] < min ) { min = _data[i]; } } return min; }
/** {@inheritDoc} */ public short max() { if ( size() == 0 ) { throw new IllegalStateException("cannot find maximum of an empty list"); } short max = Short.MIN_VALUE; for ( int i = 0; i < _pos; i++ ) { if ( _data[ i ] > max ) { max = _data[ i ]; } } return max; }
/** {@inheritDoc} */ @Override public String toString() { final StringBuilder buf = new StringBuilder( "{" ); for ( int i = 0, end = _pos - 1; i < end; i++ ) { buf.append( _data[ i ] ); buf.append( ", " ); } if ( size() > 0 ) { buf.append( _data[ _pos - 1 ] ); } buf.append( "}" ); return buf.toString(); }
/** * Removes and returns the value at the top of the stack. * * @return an <code>short</code> value */ public short pop() { return _list.removeAt( _list.size() - 1 ); }
/** * Returns the value at the top of the stack. * * @return an <code>short</code> value */ public short peek() { return _list.get( _list.size() - 1 ); }
/** * Returns a String representation of the list, top to bottom. * * @return a <code>String</code> value */ public String toString() { final StringBuilder buf = new StringBuilder( "{" ); for ( int i = _list.size() - 1; i > 0; i-- ) { buf.append( _list.get( i ) ); buf.append( ", " ); } if ( size() > 0 ) { buf.append( _list.get( 0 ) ); } buf.append( "}" ); return buf.toString(); }
/** * Returns the current depth of the stack. */ public int size() { return _list.size(); }
/** * Returns the current depth of the stack. */ @Override public int size() { return _list.size(); }
/** {@inheritDoc} */ @Override public boolean hasNext() { return cursor < size(); }
/** {@inheritDoc} */ public short max() { if ( size() == 0 ) { throw new IllegalStateException("cannot find maximum of an empty list"); } short max = Short.MIN_VALUE; for ( int i = 0; i < _pos; i++ ) { if ( _data[ i ] > max ) { max = _data[ i ]; } } return max; }
/** * Returns the value at the top of the stack. * * @return an <code>short</code> value */ public short peek() { return _list.get( _list.size() - 1 ); }
/** * Returns the value at the top of the stack. * * @return an <code>short</code> value */ public short peek() { return _list.get( _list.size() - 1 ); }
/** * Returns the value at the top of the stack. * * @return an <code>short</code> value */ public short peek() { return _list.get( _list.size() - 1 ); }
/** * Returns the value at the top of the stack. * * @return an <code>short</code> value */ @Override public short peek() { return _list.get( _list.size() - 1 ); }
/** * Removes and returns the value at the top of the stack. * * @return an <code>short</code> value */ public short pop() { return _list.removeAt( _list.size() - 1 ); }
/** * Removes and returns the value at the top of the stack. * * @return an <code>short</code> value */ public short pop() { return _list.removeAt( _list.size() - 1 ); }