BN089-BS开发框架MVC4版/source20131023/Zephyr.Net/Zephyr.Utils/Document/Excel/ExcelLibrary/CodeLib/FastSearchList.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections;
using System.Collections.Generic;
namespace QiHe.CodeLib
{
public class FastSearchList<T> : IList<T>
{
private IList<T> internalList;
private IDictionary<T, int> internalLookup;
public FastSearchList()
{
this.internalList = new List<T>();
this.internalLookup = new Dictionary<T, int>();
}
public FastSearchList(int capacity)
{
this.internalList = new List<T>(capacity);
this.internalLookup = new Dictionary<T, int>(capacity);
}
public int IndexOf(T item)
{
if (this.internalLookup.ContainsKey(item))
return this.internalLookup[item];
else
return -1;
}
public void Insert(int index, T item)
{
if (internalLookup.ContainsKey(item))
throw new ArgumentException("Duplicate item already exist in the list");
this.internalList.Insert(index, item);
this.internalLookup.Add(item, index);
// require re-indexing
for (int i = index; i < this.internalList.Count; i++)
{
T itemKey = this.internalList[i];
this.internalLookup[itemKey] = i;
}
}
public void RemoveAt(int index)
{
T item = this.internalList[index];
this.internalList.RemoveAt(index);
this.internalLookup.Remove(item);
// require re-indexing
for (int i = index; i < this.internalList.Count; i++)
{
T itemKey = this.internalList[i];
this.internalLookup[itemKey] = i;
}
}
后面还有 67 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
