/*!
  @header ECStack
  @abstract Module of Encore
 
  @availability OS X, GNUstep
  @copyright 2004, 2005, 2006 Oliver Langer

  Author: Oliver Langer

  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
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

  <pre>
  -------------------------------------------------------------------------
  Modification history

  25.06.05 ola     initial version
  22.08.06 ola     license changed
  -------------------------------------------------------------------------
  </pre>
*/

#if !defined(__ECStack_H)
#define __ECStack_H

#include <Foundation/Foundation.h>
#include <Encore/ECObject.h>

/*!
 * @class ECStack
 * @abstract A simple stack implementation
 * @discussion Implementation is synchronized
 */
@interface ECStack : ECObject {
  @private 
    NSLock *lock;
    NSMutableArray *stackData;
}

- init;
- (void) dealloc;


/*!
 * @method count
 * @result returns the number of elements of the stack
 */
- (unsigned) count;


/*!
 * @method isEmpty
 * @result YES if no data is on the stack
 */
- (BOOL) isEmpty;


/*!
 * @method isEqual
 * @abstract two stack object equal if they contain the same data in the
 *   same order.
 */
- (BOOL)isEqual: (id) anObject;


/*!
 * @method popObject
 * @abstract Removes the top element if existent.
 * @discussion The caller of the method has to release the returned reference
 * @result removes and returns the top object.  Returns nil if not existent
 */
- popObject;


/*!
 * @method pushObject
 * @abstract puts the given object on top of all objects. nil is not allowed.
 * @param toPush object to push. May not equal nil.
 * @result self
 */
- pushObject: (id) toPush;


/*!
 * @emthod topObject
 * @result returns the top object or nil if not existent
 */
- topObject;

@end
#endif
