1
나는 C++을 사용하여 Microsoft PINQ framework을 다시 구현하고 있으며 어느 시점에서 내 C++ 구현에 "Class indexer" feature of C#이 필요합니다. (Java에 대한 해결책이 있는지 궁금합니다.) 어느 누구도 좋은 도서관이나 쓸만한 것을 제안 할 수 있습니까? C++ 용 클래스 인덱서
는 C# 클래스 :/// <summary>
/// PINQAgent class resulting from the Partition operation.
/// Contains a list of epsilon values, and tracks the maximum value.
/// Increments to the maximum are forwarded to the source IQueryable.
/// Requests that do not increment the maximum are accepted.
/// </summary>
/// <typeparam name="K">The type of the key used to partition the data set.</typeparam>
//this feature is called Indexers http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx
public class PINQAgentPartition<K> : PINQAgent
{
private PINQAgent target; // agent of data source that has been partitioned.
private double[] maximum; // should be shared
private Dictionary<K, double> table; // dictionary shared among several PINQAgentPartitions.
private K key; // key associated with *this* PINQAgentPartition.
/// <summary>
/// Accepts iff the increment to the maximum value is accepted by the target.
/// </summary>
/// <param name="epsilon">epsilon</param>
/// <returns>Accepts if the increment to the maximum value is accepted by the target.</returns>
public override bool apply(double epsilon)
{
// if we increment the maximum, test and update
if (table[key] + epsilon > maximum[0])
{
if (target.apply((table[key] + epsilon) - maximum[0]))
{
table[key] += epsilon;
maximum[0] = table[key];
return true;
}
return false;
}
// if we were the maximum, and we decrement, re-establish the maximum.
if (table[key] == maximum[0] && epsilon < 0.0)
{
table[key] += epsilon;
maximum[0] = table.Select(x => x.Value).Max();
}
else
table[key] += epsilon;
return true;
}
/// <summary>
/// Constructor for PINQAgentPartition
/// </summary>
/// <param name="t">Target PINQAgent</param>
/// <param name="tbl">Table of (key,epsilon) pairs</param>
/// <param name="k">Key associated with this agent</param>
/// <param name="m">Stores a shared maximum between all peers</param>
public PINQAgentPartition(PINQAgent t, Dictionary<K, double> tbl, K k, double[] m)
{
target = (t == null) ? new PINQAgent() : t;
table = tbl;
key = k;
maximum = m;
}
};
참고 : 나는 리눅스 플랫폼에서 g ++ 컴파일러를 사용
연산자 [] 또는 연산자()를 오버로드하면 C++에서 클래스를 "색인화"할 수 있습니다. –