/// <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; }
/// <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++; }
/// <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; } }
/// <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; } }
/// <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); }
/// <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++; }
/// <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++; }
/// <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; }
/// <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); } }
/// <summary> /// Clear this queue list from all elements /// </summary> public void Clear() { Head = null; Tail = null; m_count = 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; }