Beispiel #1
0
 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
         });
     }
 }
Beispiel #2
0
 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
         });
     }
 }
Beispiel #3
0
 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);
Beispiel #4
0
 public static Segment <T, IListX <T> > NewSegIBefore <T>(this IListX <T> l, int capacity)
 => new Segment <T, IListX <T> >(l, 0, 0, capacity);
Beispiel #5
0
 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);
Beispiel #6
0
        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));
        }
Beispiel #7
0
 public BinaryHeap_List(params T[] items)
 {
     _inner = new ListX <T>(items);
     BHX.MinHeapify <T>(_inner);
 }
Beispiel #8
0
 public BinaryHeap_List(ICollection <T> items)
 {
     _inner = new ListX <T>(items);
     BHX.MinHeapify <T>(_inner);
 }
Beispiel #9
0
 //----------------------------------------------------------------------------------
 #region Ctor
 internal protected BinaryHeap_List()
 {
     _inner = null;
 }