Example #1
0
        IBlock IStack.RemoveFromBottom()
        {
            var block = BottomToTop[0];

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

            BottomToTop.RemoveAt(Size - 1);
            return(block);
        }
Example #3
0
 void IStack.AddOnTop(IStack stack)
 {
     if (stack == null)
     {
         throw new ArgumentNullException(nameof(stack));
     }
     BottomToTop.AddRange(stack.BottomToTop.Cast <Block>());
 }
Example #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);
        }
Example #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);
        }
Example #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>());
     }
 }
Example #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}.");
     }
 }
Example #8
0
 void IStack.Clear() => BottomToTop.Clear();
Example #9
0
 public string ToString(bool horizontal = false)
 {
     return(string.Join(horizontal ? " " : Environment.NewLine, BottomToTop.Reverse <Block>().Select(x => x.Id.ToString())));
 }