public UndoBuffer(int i)
 {
     BuffSize = i;
     _nElem   = 0; // pocitadlo elementu v bufferu
     bottom   = null;
     top      = null;
     current  = null;
     atBottom = true;
 }
 public object Undo()
 {
     if (current != null)
     {
         object obj = current.elem;
         if (current.prev != null)
         {
             current = current.prev;
             _nElem--;
             atBottom = false;
         }
         else
         {
             atBottom = true;
         }
         return(obj);
     }
     return(null);
 }
        public void Add2Buff(object o)
        {
            if (o != null)
            {
                BufferedObject g = new BufferedObject(o);
                if (Get_nElem == 0)
                {
                    g.next  = null;
                    g.prev  = null;
                    top     = g;
                    bottom  = g;
                    current = g;
                }
                else
                {
                    g.prev       = current;
                    g.next       = null;
                    current.next = g;
                    top          = g;
                    current      = g;
                    if (Get_nElem == 1)
                    {
                        bottom.next = g;
                    }
                }

                _nElem++;
                if (BuffSize < Get_nElem)
                {
                    bottom      = bottom.next;
                    bottom.prev = null;
                    _nElem--;
                }
                atBottom = false;
            }
        }
        public object Redo()
        {
            if (current != null)
            {
                object obj;
                if (!atBottom)
                {
                    if (current.next != null)
                    {
                        current = current.next;
                        _nElem++;
                    }
                }
                else
                {
                    atBottom = false;
                }
                obj = current.elem;

                return(obj);
            }
            //this._N_elem = count();
            return(null);
        }