コード例 #1
0
        public void InsertAfter(T item, List <T> elements)
        {
            RingElement <T> cur = Index[item];

            foreach (T value in elements)
            {
                RingElement <T> element = new RingElement <T>(value);
                Index[value] = element;
                element.Next = cur.Next;
                cur.Next     = element;
                cur          = element;
            }
        }
コード例 #2
0
        public List <T> RemoveAfter(T item, int count)
        {
            List <T>        res = new List <T>();
            RingElement <T> cur = Index[item];

            while (res.Count < count)
            {
                T value = cur.Next.Value;
                res.Add(value);
                cur.Next = cur.Next.Next;
                Index.Remove(value);
            }
            return(res);
        }
コード例 #3
0
        public FastRing(IEnumerable <T> input)
        {
            Index = new Dictionary <T, RingElement <T> >();
            RingElement <T> firstElement = null;
            RingElement <T> lastElement  = null;

            foreach (T item in input)
            {
                RingElement <T> element = new RingElement <T>(item);
                Index[item] = element;
                if (firstElement == null)
                {
                    firstElement = element;
                }
                if (lastElement != null)
                {
                    lastElement.Next = element;
                }
                lastElement = element;
            }
            lastElement.Next = firstElement;
        }
コード例 #4
0
 public RingElement(T value)
 {
     Value = value;
     Next  = null;
 }