예제 #1
0
 public override ImmutableCollection <T> AddFront(T value)
 {
     if (m_left.IsFull)
     {
         return(new NormalCollection(
                    new Two(value, m_left.Front),
                    m_middle.AddFront(m_left.RemoveFront()),
                    m_right));
     }
     else
     {
         return(new NormalCollection(m_left.AddFront(value), m_middle, m_right));
     }
 }
예제 #2
0
 public override ImmutableCollection <T> RemoveFront()
 {
     if (m_left.Size > 1)
     {
         return(new NormalCollection(m_left.RemoveFront(), m_middle, m_right));
     }
     else if (!m_middle.IsEmpty)
     {
         return(new NormalCollection(m_middle.Front, m_middle.RemoveFront(), m_right));
     }
     else if (m_right.Size > 1)
     {
         return(new NormalCollection(new One(m_right.Front), ImmutableCollection <MiniCollection> .Empty, m_right.RemoveFront()));
     }
     else
     {
         return(new SingleCollection(m_right.Front));
     }
 }