70 lines
1.3 KiB
C#
70 lines
1.3 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace CPF.ReoGrid.Data
|
|||
|
{
|
|||
|
[Serializable]
|
|||
|
public sealed class DictionaryTreeArray<T>
|
|||
|
{
|
|||
|
public T this[int row, int col]
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
long key = (long)(row >> 12 << 16 | col >> 8);
|
|||
|
bool flag = !this.data.ContainsKey(key);
|
|||
|
T result;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
result = default(T);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
int num = (row >> 6) % 64;
|
|||
|
int num2 = (col >> 4) % 16;
|
|||
|
T[,] array = this.data[key][num, num2];
|
|||
|
result = ((array == null) ? default(T) : array[row % 64, col % 16]);
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
long key = (long)(row >> 12 << 16 | col >> 8);
|
|||
|
bool flag = !this.data.ContainsKey(key);
|
|||
|
T[,][,] array;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
bool flag2 = value == null;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
this.data.Add(key, array = new T[64, 16][,]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
array = this.data[key];
|
|||
|
}
|
|||
|
int num = (row >> 6) % 64;
|
|||
|
int num2 = (col >> 4) % 16;
|
|||
|
bool flag3 = array[num, num2] == null;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
bool flag4 = value == null;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
array[num, num2] = new T[64, 16];
|
|||
|
}
|
|||
|
array[num, num2][row % 64, col % 16] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public const int RowSize = 64;
|
|||
|
|
|||
|
public const int ColSize = 16;
|
|||
|
|
|||
|
private Dictionary<long, T[,][,]> data = new Dictionary<long, T[,][,]>();
|
|||
|
}
|
|||
|
}
|