Exemplo n.º 1
0
        IBlock IStack.RemoveFromBottom()
        {
            var block = BottomToTop[0];

            BottomToTop.RemoveAt(0);
            return(block);
        }
Exemplo n.º 2
0
        IBlock IStack.RemoveFromTop()
        {
            var block = BottomToTop[Size - 1];

            BottomToTop.RemoveAt(Size - 1);
            return(block);
        }
Exemplo n.º 3
0
 void IStack.AddOnTop(IStack stack)
 {
     if (stack == null)
     {
         throw new ArgumentNullException(nameof(stack));
     }
     BottomToTop.AddRange(stack.BottomToTop.Cast <Block>());
 }
Exemplo n.º 4
0
        IStack IStack.RemoveFromBottom(int amount)
        {
            var split = new Stack();

            for (var i = 0; i < amount; i++)
            {
                split.BottomToTop.Add(BottomToTop[i]);
            }

            BottomToTop.RemoveRange(0, amount);
            return(split);
        }
Exemplo n.º 5
0
        IStack IStack.RemoveFromTop(int amount)
        {
            var split = new Stack();

            for (var i = amount; i > 0; i--)
            {
                split.BottomToTop.Add(BottomToTop[Size - i]);
            }

            BottomToTop.RemoveRange(Size - amount, amount);
            return(split);
        }
Exemplo n.º 6
0
 void IStack.AddToBottom(IStack stack)
 {
     if (stack == null)
     {
         throw new ArgumentNullException(nameof(stack));
     }
     if (BottomToTop.Count > 0)
     {
         BottomToTop.InsertRange(0, stack.BottomToTop.Cast <Block>());
     }
     else
     {
         BottomToTop.AddRange(stack.BottomToTop.Cast <Block>());
     }
 }
Exemplo n.º 7
0
 void IStack.AddOnTop(IBlock block)
 {
     if (block == null)
     {
         throw new ArgumentNullException(nameof(block));
     }
     if (block is Block b)
     {
         BottomToTop.Add(b);
     }
     else
     {
         throw new ArgumentException($"Wrong type of block: Expected {typeof(Block).FullName}, received {block.GetType().FullName}.");
     }
 }
Exemplo n.º 8
0
 void IStack.Clear() => BottomToTop.Clear();
Exemplo n.º 9
0
 public string ToString(bool horizontal = false)
 {
     return(string.Join(horizontal ? " " : Environment.NewLine, BottomToTop.Reverse <Block>().Select(x => x.Id.ToString())));
 }