diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/MinHeap.cs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/OpenSim/Framework/MinHeap.cs b/OpenSim/Framework/MinHeap.cs index 68f6668..2149b8a 100644 --- a/OpenSim/Framework/MinHeap.cs +++ b/OpenSim/Framework/MinHeap.cs | |||
@@ -84,7 +84,7 @@ namespace OpenSim.Framework | |||
84 | private int size; | 84 | private int size; |
85 | private object sync_root; | 85 | private object sync_root; |
86 | private int version; | 86 | private int version; |
87 | private int capacity; | 87 | private int minCapacity; |
88 | 88 | ||
89 | private Comparison<T> comparison; | 89 | private Comparison<T> comparison; |
90 | 90 | ||
@@ -96,8 +96,8 @@ namespace OpenSim.Framework | |||
96 | public MinHeap(Comparison<T> comparison) : this(DEFAULT_CAPACITY, comparison) { } | 96 | public MinHeap(Comparison<T> comparison) : this(DEFAULT_CAPACITY, comparison) { } |
97 | public MinHeap(int _capacity, Comparison<T> _comparison) | 97 | public MinHeap(int _capacity, Comparison<T> _comparison) |
98 | { | 98 | { |
99 | capacity = _capacity; | 99 | minCapacity = _capacity; |
100 | items = new HeapItem[capacity]; | 100 | items = new HeapItem[minCapacity]; |
101 | comparison = _comparison; | 101 | comparison = _comparison; |
102 | size = version = 0; | 102 | size = version = 0; |
103 | } | 103 | } |
@@ -236,10 +236,10 @@ namespace OpenSim.Framework | |||
236 | { | 236 | { |
237 | if (size == items.Length) | 237 | if (size == items.Length) |
238 | { | 238 | { |
239 | int capacity = (int)((items.Length * 200L) / 100L); | 239 | int newcapacity = (int)((items.Length * 200L) / 100L); |
240 | if (capacity < (items.Length + DEFAULT_CAPACITY)) | 240 | if (newcapacity < (items.Length + DEFAULT_CAPACITY)) |
241 | capacity = items.Length + DEFAULT_CAPACITY; | 241 | newcapacity = items.Length + DEFAULT_CAPACITY; |
242 | Array.Resize<HeapItem>(ref items, capacity); | 242 | Array.Resize<HeapItem>(ref items, newcapacity); |
243 | } | 243 | } |
244 | 244 | ||
245 | Handle handle = null; | 245 | Handle handle = null; |
@@ -273,8 +273,8 @@ namespace OpenSim.Framework | |||
273 | for (int index = 0; index < size; ++index) | 273 | for (int index = 0; index < size; ++index) |
274 | items[index].Clear(); | 274 | items[index].Clear(); |
275 | size = 0; | 275 | size = 0; |
276 | if(items.Length > capacity) | 276 | if(items.Length > minCapacity) |
277 | items = new HeapItem[capacity]; | 277 | items = new HeapItem[minCapacity]; |
278 | ++version; | 278 | ++version; |
279 | } | 279 | } |
280 | 280 | ||
@@ -282,7 +282,7 @@ namespace OpenSim.Framework | |||
282 | { | 282 | { |
283 | int length = (int)(items.Length * 0.9); | 283 | int length = (int)(items.Length * 0.9); |
284 | if (size < length) | 284 | if (size < length) |
285 | Array.Resize<HeapItem>(ref items, Math.Min(size, capacity)); | 285 | Array.Resize<HeapItem>(ref items, Math.Min(size, minCapacity)); |
286 | } | 286 | } |
287 | 287 | ||
288 | private void RemoveAt(int index) | 288 | private void RemoveAt(int index) |
@@ -300,8 +300,8 @@ namespace OpenSim.Framework | |||
300 | if (!BubbleUp(index)) | 300 | if (!BubbleUp(index)) |
301 | BubbleDown(index); | 301 | BubbleDown(index); |
302 | } | 302 | } |
303 | if(size == 0 && items.Length > 4 * capacity) | 303 | if(size == 0 && items.Length > 4 * minCapacity) |
304 | items = new HeapItem[capacity]; | 304 | items = new HeapItem[minCapacity]; |
305 | } | 305 | } |
306 | 306 | ||
307 | public T RemoveMin() | 307 | public T RemoveMin() |