// This may look like C code, but it is really -*- C++ -*-
// 
// <copyright> 
//  
//  Copyright (c) 1996
//  Institute for Information Processing and Computer Supported New Media (IICM), 
//  Graz University of Technology, Austria. 
//  
// </copyright> 
// 
// 
// <file> 
// 
// Name:        deque_t.h
// 
// Purpose:     
// 
// Created:     5 Jul 96   Joerg Faschingbauer
// 
// Modified:    
// 
// Description: 
// 
// $Id: deque_t.h,v 1.2 1997/02/12 20:12:22 jfasch Exp $
// 
// $Log: deque_t.h,v $
// Revision 1.2  1997/02/12 20:12:22  jfasch
// moved to utils
//
// Revision 1.1  1996/07/08 13:16:36  jfasch
// Initial revision
//
// 
// </file> 
#ifndef hg_utils_deque_t_h
#define hg_utils_deque_t_h

#include "fields.h"

#define Dequedeclare(d, t)	typedef Deque<t> d

template<class T>
class Deque : public Field<T> {
public:
   int count() const ;
   void push (const T&) ;
   bool shift (T&) ;
   T shift() ;
   void unshift (const T&) ;
} ;

template<class T>
inline void Deque<T> :: push (const T& d) {
   append (d); 
}

template<class T>
inline void Deque<T> :: unshift (const T& d) {
    insert (0, d);
}

template<class T>
inline T Deque<T> :: shift() {
   T d ;
   shift (d) ;
   return d ;
}

template<class T>
bool Deque<T> :: shift (T& d) {
   if (! count())
      return false ;
   d = Deque<T>::operator[] (0) ;
   Deque<T>::remove (0) ;
   return true ;
}

#endif
