code aesthetics

0.9.1.0-post-fixes
UbitUmarov 2018-11-17 17:35:47 +00:00
parent efd6fb05a9
commit 852e20a5a7
1 changed files with 12 additions and 12 deletions

View File

@ -84,7 +84,7 @@ namespace OpenSim.Framework
private int size; private int size;
private object sync_root; private object sync_root;
private int version; private int version;
private int capacity; private int minCapacity;
private Comparison<T> comparison; private Comparison<T> comparison;
@ -96,8 +96,8 @@ namespace OpenSim.Framework
public MinHeap(Comparison<T> comparison) : this(DEFAULT_CAPACITY, comparison) { } public MinHeap(Comparison<T> comparison) : this(DEFAULT_CAPACITY, comparison) { }
public MinHeap(int _capacity, Comparison<T> _comparison) public MinHeap(int _capacity, Comparison<T> _comparison)
{ {
capacity = _capacity; minCapacity = _capacity;
items = new HeapItem[capacity]; items = new HeapItem[minCapacity];
comparison = _comparison; comparison = _comparison;
size = version = 0; size = version = 0;
} }
@ -236,10 +236,10 @@ namespace OpenSim.Framework
{ {
if (size == items.Length) if (size == items.Length)
{ {
int capacity = (int)((items.Length * 200L) / 100L); int newcapacity = (int)((items.Length * 200L) / 100L);
if (capacity < (items.Length + DEFAULT_CAPACITY)) if (newcapacity < (items.Length + DEFAULT_CAPACITY))
capacity = items.Length + DEFAULT_CAPACITY; newcapacity = items.Length + DEFAULT_CAPACITY;
Array.Resize<HeapItem>(ref items, capacity); Array.Resize<HeapItem>(ref items, newcapacity);
} }
Handle handle = null; Handle handle = null;
@ -273,8 +273,8 @@ namespace OpenSim.Framework
for (int index = 0; index < size; ++index) for (int index = 0; index < size; ++index)
items[index].Clear(); items[index].Clear();
size = 0; size = 0;
if(items.Length > capacity) if(items.Length > minCapacity)
items = new HeapItem[capacity]; items = new HeapItem[minCapacity];
++version; ++version;
} }
@ -282,7 +282,7 @@ namespace OpenSim.Framework
{ {
int length = (int)(items.Length * 0.9); int length = (int)(items.Length * 0.9);
if (size < length) if (size < length)
Array.Resize<HeapItem>(ref items, Math.Min(size, capacity)); Array.Resize<HeapItem>(ref items, Math.Min(size, minCapacity));
} }
private void RemoveAt(int index) private void RemoveAt(int index)
@ -300,8 +300,8 @@ namespace OpenSim.Framework
if (!BubbleUp(index)) if (!BubbleUp(index))
BubbleDown(index); BubbleDown(index);
} }
if(size == 0 && items.Length > 4 * capacity) if(size == 0 && items.Length > 4 * minCapacity)
items = new HeapItem[capacity]; items = new HeapItem[minCapacity];
} }
public T RemoveMin() public T RemoveMin()