15 protected ArrayList InnerList =
new ArrayList();
30 InnerList.Capacity = Capacity;
36 InnerList = Core.Clone() as ArrayList;
45 object h = InnerList[i];
46 InnerList[i] = InnerList[j];
52 return Comparer.Compare(InnerList[i],InnerList[j]);
55 #region public methods 56 public int Push(
object O)
63 int p = InnerList.Count,p2;
87 object result = InnerList[0];
89 InnerList[0] = InnerList[InnerList.Count-1];
90 InnerList.RemoveAt(InnerList.Count-1);
96 if(InnerList.Count>p1 && OnCompare(p,p1)>0)
98 if(InnerList.Count>p2 && OnCompare(p,p2)>0)
103 SwitchElements(p,pn);
125 if(OnCompare(p,p2)<0)
127 SwitchElements(p,p2);
140 if(InnerList.Count>p1 && OnCompare(p,p1)>0)
142 if(InnerList.Count>p2 && OnCompare(p,p2)>0)
147 SwitchElements(p,pn);
157 if(InnerList.Count>0)
164 return InnerList.Contains(value);
176 return InnerList.Count;
179 IEnumerator IEnumerable.GetEnumerator()
181 return InnerList.GetEnumerator();
184 public void CopyTo(Array array,
int index)
186 InnerList.CopyTo(array,index);
194 public bool IsSynchronized
198 return InnerList.IsSynchronized;
202 public object SyncRoot
210 #region explicit implementation 211 bool IList.IsReadOnly
219 object IList.this[
int index]
223 return InnerList[index];
227 InnerList[index] = value;
232 int IList.Add(
object o)
237 void IList.RemoveAt(
int index)
239 throw new NotSupportedException();
242 void IList.Insert(
int index,
object value)
244 throw new NotSupportedException();
247 void IList.Remove(
object value)
249 throw new NotSupportedException();
252 int IList.IndexOf(
object value)
254 throw new NotSupportedException();
257 bool IList.IsFixedSize
void CopyTo(Array array, int index)
virtual int OnCompare(int i, int j)
BinaryPriorityQueue(ArrayList Core, IComparer Comp, bool Copy)
BinaryPriorityQueue(int C)
BinaryPriorityQueue(IComparer c, int Capacity)
object Pop()
Get the smallest object and remove it.
void Update(int i)
Notify the PQ that the object at position i has changed and the PQ needs to restore order...
static BinaryPriorityQueue ReadOnly(BinaryPriorityQueue P)
void SwitchElements(int i, int j)
bool Contains(object value)
static BinaryPriorityQueue Syncronized(BinaryPriorityQueue P)
object Peek()
Get the smallest object without removing it.
BinaryPriorityQueue(IComparer c)