mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-16 22:16:55 +07:00
little refactor
This commit is contained in:
@@ -42,7 +42,7 @@ namespace IsoTools.Internal {
|
||||
return false;
|
||||
}
|
||||
_dict.Add(item, _list.Count);
|
||||
_list.Push(item);
|
||||
_list.Add(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,12 @@ namespace IsoTools.Internal {
|
||||
return false;
|
||||
}
|
||||
|
||||
public T Pop() {
|
||||
var item = _list.Pop();
|
||||
_dict.Remove(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_list.Clear();
|
||||
_dict.Clear();
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace IsoTools.Internal {
|
||||
}
|
||||
}
|
||||
|
||||
public void Push(T value) {
|
||||
public void Add(T value) {
|
||||
if ( _size == _data.Length ) {
|
||||
var new_capacity = _size == 0
|
||||
? _defaultCapacity : _size * 2;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace IsoTools.Internal {
|
||||
namespace IsoTools.Internal {
|
||||
public interface IsoIPool<T> {
|
||||
T Take();
|
||||
void Release(T item);
|
||||
@@ -12,7 +10,7 @@ namespace IsoTools.Internal {
|
||||
public IsoPool(int capacity) {
|
||||
_items = new IsoList<T>(capacity);
|
||||
for ( var i = 0; i < capacity; ++i ) {
|
||||
_items.Push(CreateItem());
|
||||
_items.Add(CreateItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +21,8 @@ namespace IsoTools.Internal {
|
||||
}
|
||||
|
||||
public void Release(T item) {
|
||||
if ( item == null ) {
|
||||
throw new ArgumentNullException("item");
|
||||
}
|
||||
CleanUpItem(item);
|
||||
_items.Push(item);
|
||||
_items.Add(item);
|
||||
}
|
||||
|
||||
public abstract T CreateItem();
|
||||
|
||||
@@ -562,7 +562,7 @@ namespace IsoTools {
|
||||
_sectors.Capacity = count;
|
||||
}
|
||||
while ( _sectors.Count < _sectors.Capacity ) {
|
||||
_sectors.Push(new Sector());
|
||||
_sectors.Add(new Sector());
|
||||
}
|
||||
}
|
||||
for ( int i = 0, e = _sectors.Count; i < e; ++i ) {
|
||||
@@ -581,7 +581,7 @@ namespace IsoTools {
|
||||
for ( var x = min.x; x < max.x; ++x ) {
|
||||
var sector = FindSector(x, y);
|
||||
if ( sector != null ) {
|
||||
sector.objects.Push(iso_object);
|
||||
sector.objects.Add(iso_object);
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user