Beispiel #1
0
        /// <summary>
        /// sort utilizing bucket sort
        /// </summary>
        /// <typeparam name="SubelementType">subelement type</typeparam>
        /// <param name="mapper">keymapper mapping subelement items to buckets</param>
        public void Sort <SubelementType>(ILKeyMapper <T1, SubelementType> mapper)
        {
            ILQueueList <T1, T2> ret = ILBucketSort.BucketSort <T1, SubelementType, T2>(this, null, mapper, ILBucketSort.SortMethod.ConstantLength);

            this.Head = ret.Head;
            this.Tail = ret.Tail;
        }
Beispiel #2
0
        /// <summary>
        /// Add to start of queue
        /// </summary>
        /// <param name="item">item data to add to start of queue</param>
        public void AddToStart(T1 item)
        {
            ILListItem <T1, T2> newLItem = new ILListItem <T1, T2>(item);

            newLItem.Next = Head;
            Head          = newLItem;
            m_count++;
        }
Beispiel #3
0
        /// <summary>
        /// gives enumerator for internal list items (ILListItem)
        /// </summary>
        /// <returns>ILListItem's</returns>
        IEnumerator IEnumerable.GetEnumerator()
        {
            ILListItem <T1, T2> curr = Head;

            while (curr != null)
            {
                yield return(curr);

                curr = curr.Next;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Create enumerator utilizing 'foreach'
        /// </summary>
        /// <returns>enumerator for contained elements</returns>
        public IEnumerator <T1> GetEnumerator()
        {
            ILListItem <T1, T2> curr = Head;

            while (curr != null)
            {
                yield return(curr.Data);

                curr = curr.Next;
            }
        }
Beispiel #5
0
        /// <summary>
        /// convert (copy) items to system array
        /// </summary>
        /// <returns>system array with items</returns>
        public T1[] ToArray()
        {
            T1[] ret = new T1[m_count];
            ILListItem <T1, T2> curr = Head;

            for (int i = 0; curr != null; i++)
            {
                ret[i] = curr.Data;
                curr   = curr.Next;
            }
            return(ret);
        }
Beispiel #6
0
 /// <summary>
 /// add indexed item at end of queue
 /// </summary>
 public void Enqueue(T1 item, T2 index)
 {
     if (Head == null)
     {
         Head = new ILListItem <T1, T2>(item, index);
         Tail = Head;
     }
     else
     {
         ILListItem <T1, T2> newItem = new ILListItem <T1, T2>(item, index);
         Tail.Next = newItem;
         Tail      = newItem;
     }
     m_count++;
 }
Beispiel #7
0
 /// <summary>
 /// add item at end of queue
 /// </summary>
 public void Enqueue(ILListItem <T1, T2> item)
 {
     System.Diagnostics.Debug.Assert(item.Next == null);
     if (Head == null)
     {
         Head = item;
         Tail = item;
     }
     else
     {
         Tail.Next = item;
         Tail      = item;
     }
     m_count++;
 }
Beispiel #8
0
 /// <summary>
 /// add queue list to end of this queue list
 /// </summary>
 /// <param name="list">queue list to be added</param>
 public void Enqueue(ILQueueList <T1, T2> list)
 {
     if (list == null || list.Count == 0)
     {
         return;
     }
     if (Tail != null)
     {
         Tail.Next = list.Head;
         Tail      = list.Tail;
     }
     else
     {
         Head = list.Head;
         Tail = list.Tail;
     }
     m_count += list.m_count;
 }
Beispiel #9
0
        /// <summary>
        /// Remove from start of queue
        /// </summary>
        /// <returns>item from start of queue</returns>
        public ILListItem <T1, T2> Dequeue()
        {
            switch (m_count)
            {
            case 0:
                return(null);

            case 1:
                ILListItem <T1, T2> retIt = Head;
                Head = null;
                Tail = null;
                m_count--;
                System.Diagnostics.Debug.Assert(retIt.Next == null);
                return(retIt);

            default:
                retIt = Head;
                Head  = Head.Next;
                m_count--;
                retIt.Next = null;
                return(retIt);
            }
        }
Beispiel #10
0
 /// <summary>
 /// Clear this queue list from all elements
 /// </summary>
 public void Clear()
 {
     Head    = null;
     Tail    = null;
     m_count = 0;
 }
Beispiel #11
0
 /// <summary>
 /// concatenate 2 queuelists
 /// </summary>
 /// <param name="qlist">queue list to be added at start of this queuelist</param>
 public void AddToStart(ILQueueList <T1, T2> qlist)
 {
     m_count        += qlist.m_count;
     qlist.Tail.Next = Head;
     Head            = qlist.Head;
 }