I need a very specific class, I would really like to know if it exists, so I do not need to reimplement it. I have a set of items. Each element has a numerical value associated with it - weight. The weight of each item is unique in the set. Items must be sorted by weight. Weight can be changed for each item, but the weight change operation is extremely expensive. There is an operation that is performed with a frequent set - moving the range of elements within the set by changing the weight of the element. Therefore, I need a class of the List class, but with built-in logic to control the weights of the elements. The sequence of weights must be sparse to minimize weight collisions during movement and to improve productivity while minimizing weight change operations. The class interface should look like this:
public abstract class SparsedSequence<T> : IList<T>
{
private int WeightIncrement = 10000;
protected abstract void OnWeightChanged(int weight, T item);
public void MoveRange(int offset, int count, int amount)
{
}
public void MoveRange(T[] range, int amount)
{
}
public int ConstraintAmount(int offset, int count, int amount)
{
}
public int ConstraintAmount(T[] range, int amount)
{
}
public void Add(T newItem)
{
}
public void Add(T item, int weight)
{
}
public T this[int index]
{
get { ... }
}
public IList<int> Weights
{
get { ... }
}
public KeyValuePair<int, T> this[int index]
{
get { ... }
}
}
Did not find anything like this in a wireframe or PowerCollections. I assume that you already realized that I intend to use this class to control the write operations in the backup database :) Thanks.