… get in the queue.

OK, so yesterday I returned with a really simple piece of code that’s convenient when building stack frames.

After stacks, the next easiest/most convenient structure has to be the queue.  No surprise then that .NET has a similarly generic

Queue 

 class.

It seems appropriate to give it the same treatment –

public class Queue<T1, T2> : Queue<Tuple<T1, T2>>
{
    public void Enqueue(T1 item1, T2 item2)
    {
        Enqueue(new Tuple<T1, T2>(item1, item2));
    }
}

public class Queue<T1, T2, T3> : Queue<Tuple<T1, T2, T3>>
{
    public void Enqueue(T1 item1, T2 item2, T3 item3)
    {
        Enqueue(new Tuple<T1, T2, T3>(item1, item2, item3));
    }
}
public class Queue<T1, T2, T3, T4> : Queue<Tuple<T1, T2, T3, T4>>
{
    public void Enqueue(T1 item1, T2 item2, T3 item3, T4 item4)
    {
        Enqueue(new Tuple<T1, T2, T3, T4>(item1, item2, item3, item4));
    }
}
public class Queue<T1, T2, T3, T4, T5> : Queue<Tuple<T1, T2, T3, T4, T5>>
{
    public void Enqueue(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
    {
        Enqueue(new Tuple<T1, T2, T3, T4, T5>(item1, item2, item3, item4, item5));
    }
}
public class Queue<T1, T2, T3, T4, T5, T6> : Queue<Tuple<T1, T2, T3, T4, T5, T6>>
{
    public void Enqueue(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
    {
        Enqueue(new Tuple<T1, T2, T3, T4, T5, T6>(item1, item2, item3, item4, item5, item6));
    }
}
public class Queue<T1, T2, T3, T4, T5, T6, T7> : Queue<Tuple<T1, T2, T3, T4, T5, T6, T7>>
{
    public void Enqueue(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
    {
        Enqueue(new Tuple<T1, T2, T3, T4, T5, T6, T7>(item1, item2, item3, item4, item5, item6, item7));
    }
}
public class Queue<T1, T2, T3, T4, T5, T6, T7, TRest> : Queue<Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>>
{
    public void Enqueue(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
    {
        Enqueue(new Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>(item1, item2, item3, item4, item5, item6, item7, rest));
    }
}

I won’t insult you with example usage, but hopefully I’ve saved someone some typing.

Related Images: