Files
Dec2017-Script-Dump/KdTreeLib/NearestNeighbourList.cs
T
2026-06-04 11:42:34 +02:00

99 lines
2.3 KiB
C#

using System;
namespace KdTree
{
// Token: 0x0200000C RID: 12
public class NearestNeighbourList<TItem, TDistance> : INearestNeighbourList<TItem, TDistance>
{
// Token: 0x0600004C RID: 76 RVA: 0x00002CB7 File Offset: 0x00000EB7
public NearestNeighbourList(int maxCapacity, ITypeMath<TDistance> distanceMath)
{
this.maxCapacity = maxCapacity;
this.distanceMath = distanceMath;
this.queue = new PriorityQueue<TItem, TDistance>(maxCapacity, distanceMath);
}
// Token: 0x17000010 RID: 16
// (get) Token: 0x0600004D RID: 77 RVA: 0x00002CDA File Offset: 0x00000EDA
public int MaxCapacity
{
get
{
return this.maxCapacity;
}
}
// Token: 0x17000011 RID: 17
// (get) Token: 0x0600004E RID: 78 RVA: 0x00002CE2 File Offset: 0x00000EE2
public int Count
{
get
{
return this.queue.Count;
}
}
// Token: 0x0600004F RID: 79 RVA: 0x00002CF0 File Offset: 0x00000EF0
public bool Add(TItem item, TDistance distance)
{
if (this.queue.Count < this.maxCapacity)
{
this.queue.Enqueue(item, distance);
return true;
}
if (this.distanceMath.Compare(distance, this.queue.GetHighestPriority()) < 0)
{
this.queue.Dequeue();
this.queue.Enqueue(item, distance);
return true;
}
return false;
}
// Token: 0x06000050 RID: 80 RVA: 0x00002D55 File Offset: 0x00000F55
public TItem GetFurtherest()
{
if (this.Count == 0)
{
throw new Exception("List is empty");
}
return this.queue.GetHighest();
}
// Token: 0x06000051 RID: 81 RVA: 0x00002D75 File Offset: 0x00000F75
public TDistance GetFurtherestDistance()
{
if (this.Count == 0)
{
throw new Exception("List is empty");
}
return this.queue.GetHighestPriority();
}
// Token: 0x06000052 RID: 82 RVA: 0x00002D95 File Offset: 0x00000F95
public TItem RemoveFurtherest()
{
return this.queue.Dequeue();
}
// Token: 0x17000012 RID: 18
// (get) Token: 0x06000053 RID: 83 RVA: 0x00002DA2 File Offset: 0x00000FA2
public bool IsCapacityReached
{
get
{
return this.Count == this.MaxCapacity;
}
}
// Token: 0x04000014 RID: 20
private PriorityQueue<TItem, TDistance> queue;
// Token: 0x04000015 RID: 21
private ITypeMath<TDistance> distanceMath;
// Token: 0x04000016 RID: 22
private int maxCapacity;
}
}