Example #1
0
    private void CheckListOrder(IDoubleLinkedList <int> list)
    {
        //0
        Assert.NotEqual(list.First, null);
        Assert.NotEqual(list.First.Next, null);
        Assert.Equal(list.First.Prev, null);
        Assert.Equal(list.First.Value, 0);

        //1
        Assert.NotEqual(list.First.Next.Next, null);
        Assert.NotEqual(list.First.Next.Prev, null);
        Assert.Equal(list.First.Next.Value, 1);

        //2
        Assert.NotEqual(list.First.Next.Next.Next, null);
        Assert.NotEqual(list.First.Next.Next.Prev, null);
        Assert.Equal(list.First.Next.Next.Value, 2);

        //3
        Assert.NotEqual(list.First.Next.Next.Next.Next, null);
        Assert.NotEqual(list.First.Next.Next.Next.Prev, null);
        Assert.Equal(list.First.Next.Next.Next.Value, 3);

        //4
        Assert.NotEqual(list.Last, null);
        Assert.NotEqual(list.Last.Prev, null);
        Assert.Equal(list.Last.Next, null);
        Assert.Equal(list.Last.Value, 4);

        Assert.Equal((int)list.Count, 5);
    }
Example #2
0
 /// <summary>
 /// move to last element in IDoubleLinkedList
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="current"></param>
 /// <returns></returns>
 public static IDoubleLinkedList <T> FastForward <T>(this IDoubleLinkedList <T> current)
 {
     while (current.Next != null)
     {
         current = current.Next ?? throw new NullReferenceException();
     }
     return(current);
 }
Example #3
0
 /// <summary>
 /// move for first element in IDoubleLinkedList
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="current"></param>
 /// <returns></returns>
 public static IDoubleLinkedList <T> Rewind <T>(this IDoubleLinkedList <T> current)
 {
     while (current.Previous != null)
     {
         current = current.Previous ?? throw new NullReferenceException();
     }
     return(current);
 }
        public ElementNotFoundException(TValue value, IDoubleLinkedList <TValue> list)
        {
            var msgValue = string.Format(expectedMessageValue, value);

            foreach (var item in list)
            {
                expectedMessageList += item.ToString();
            }

            _message = msgValue + expectedMessageList;
        }
Example #5
0
 /// <summary>
 /// try moving to realative position
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="current"></param>
 /// <param name="count"></param>
 /// <returns></returns>
 public static IDoubleLinkedList <T> Offset <T>(this IDoubleLinkedList <T> current, int count) =>
 count switch
 {
Example #6
0
 public Cache(IDoubleLinkedList doubleLinkedList, int size = 100)
 {
     Size = size;
     _doubleLinkedList = doubleLinkedList;
     _cacheStore       = new ConcurrentDictionary <string, object>();
 }