function queue = queue(varargin)
%QUEUE constructor for queue object
% usage:
%   q  = queue    - Default constructor, empty queue table
%   mq = queue(q) - Copy constructor 
%
% example:
%   q = queue 
%   q = push(q, [1:2])
%   q = push(q, ones(1,5))
%   q = undo(q)
%   data = get(q)
%   q = push(q, zeros(1,3))
%   etc ...
%
% $Id$

% todos: define maxSize dimension
% if nargin == 1 && isa(varargin{1},'integer')
%   q.maxSize = varargin{1};
% end
% and test maxSize in push

% copy constructor
% ----------------
if nargin == 1 && isa(varargin{1},'queue')
  queue = varargin{1};
  return;
    
% default constructor
% -------------------
elseif nargin == 0

  % current index inside of queue, change by undo & redo 
  % ----------------------------------------------------
  q.index = 0;
  
  % number of object currently stored 
  % ---------------------------------
  q.size = 0;
  
  % buffer where objects are stored
  % -------------------------------
  q.buffer = {};
  
  % one object buffer, prepared by undo & redo methods and disposed for get method
  % -----------------------------------------------------------------------
  q.data = {};
  
else
  error('queue:queue', 'Invalid arguments.');
end

% class constructor
% -----------------
queue = class(q,'queue');