public static IBinaryHeap <T, T> Wrap <T>(this IListX <T> inner, int count, long offset = 0) where T : IComparable <T> { if (inner == null) { throw new ArgumentNullException("BinaryHeap_List inner list can not be null"); } if (inner is T[]) { T[] _inner = inner as T[]; if (offset == 0) { BHX.MinHeapify <T>(_inner, count); } else { BHX.MinHeapify <T>(_inner, count, offset); } return(new BinaryHeap_Array <T>() { _inner = _inner.Segment(offset, count) }); } else if (inner is ArraySeg <T> ) { var _inner = (ArraySeg <T>)inner; _inner = _inner.SubShift(offset, count, count); if (_inner._offset == 0) { BHX.MinHeapify <T>(_inner._inner, _inner._count); } else { BHX.MinHeapify <T>(_inner._inner, _inner._count, _inner._offset); } return(new BinaryHeap_Array <T>() { _inner = _inner }); } else if (inner is Segment <T, IListX <T> > ) { var _inner = (Segment <T, IListX <T> >)inner; _inner = _inner.SubShift((int)offset, count, count); BHX.MinHeapify <T>(_inner); return(new BinaryHeap_List <T>() { _inner = _inner }); } else { var _inner = inner.SegmentI((int)offset, count); BHX.MinHeapify <T>(_inner); return(new BinaryHeap_List <T>() { _inner = _inner }); } }
public static IBinaryHeap <T, P> Wrap <T, P>(this IListX <T> inner)//, P priorityRef) where T : IPriority <P> where P : IComparable <P> { if (inner == null) { throw new ArgumentNullException("BinaryHeap_List inner list can not be null"); } if (inner is T[]) { T[] _inner = inner as T[]; BHX.MinHeapify <T, P>(_inner); return(new BinaryHeap_Array <T, P>() { _inner = _inner.Segment(0, _inner.Length) }); } else if (inner is ArraySeg <T> ) { var _inner = (ArraySeg <T>)inner; if (_inner._offset == 0) { BHX.MinHeapify <T, P>(_inner._inner, _inner._count); } else { BHX.MinHeapify <T, P>(_inner._inner, _inner._count, _inner._offset); } return(new BinaryHeap_Array <T, P>() { _inner = _inner }); } else if (inner is Segment <T, IListX <T> > ) { var _inner = (Segment <T, IListX <T> >)inner; BHX.MinHeapify <T, P>(_inner); return(new BinaryHeap_List <T, P>() { _inner = _inner }); } else { BHX.MinHeapify <T, P>(inner); return(new BinaryHeap_List <T, P>() { _inner = inner }); } }
public static Segment <T, IListX <T> > NewSegIFrom <T>(this IListX <T> l, int offset) => new Segment <T, IListX <T> >(l, offset, 0, l.Count - offset);
public static Segment <T, IListX <T> > NewSegIBefore <T>(this IListX <T> l, int capacity) => new Segment <T, IListX <T> >(l, 0, 0, capacity);
public static Segment <T, IListX <T> > NewSegI <T>(this IListX <T> l, int offset, int capacity) => new Segment <T, IListX <T> >(l, offset, 0, capacity);
public static Segment <T, IListX <T> > SegmentIFrom <T>(this IListX <T> l, int offset) { var count = l.Count - offset; return(new Segment <T, IListX <T> >(l, offset, count, count)); }
public BinaryHeap_List(params T[] items) { _inner = new ListX <T>(items); BHX.MinHeapify <T>(_inner); }
public BinaryHeap_List(ICollection <T> items) { _inner = new ListX <T>(items); BHX.MinHeapify <T>(_inner); }
//---------------------------------------------------------------------------------- #region Ctor internal protected BinaryHeap_List() { _inner = null; }