本文整理汇总了C#中ISet.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# ISet.Clear方法的具体用法?C# ISet.Clear怎么用?C# ISet.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISet
的用法示例。
在下文中一共展示了ISet.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessCertD
internal static PkixPolicyNode ProcessCertD(
PkixCertPath certPath,
int index,
ISet acceptablePolicies,
PkixPolicyNode validPolicyTree,
IList[] policyNodes,
int inhibitAnyPolicy)
//throws CertPathValidatorException
{
IList certs = certPath.Certificates;
X509Certificate cert = (X509Certificate)certs[index];
int n = certs.Count;
// i as defined in the algorithm description
int i = n - index;
//
// (d) policy Information checking against initial policy and
// policy mapping
//
Asn1Sequence certPolicies = null;
try
{
certPolicies = DerSequence.GetInstance(
PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.CertificatePolicies));
}
catch (Exception e)
{
throw new PkixCertPathValidatorException(
"Could not read certificate policies extension from certificate.", e, certPath, index);
}
if (certPolicies != null && validPolicyTree != null)
{
//
// (d) (1)
//
ISet pols = new HashSet();
foreach (Asn1Encodable ae in certPolicies)
{
PolicyInformation pInfo = PolicyInformation.GetInstance(ae.ToAsn1Object());
DerObjectIdentifier pOid = pInfo.PolicyIdentifier;
pols.Add(pOid.Id);
if (!Rfc3280CertPathUtilities.ANY_POLICY.Equals(pOid.Id))
{
ISet pq = null;
try
{
pq = PkixCertPathValidatorUtilities.GetQualifierSet(pInfo.PolicyQualifiers);
}
catch (PkixCertPathValidatorException ex)
{
throw new PkixCertPathValidatorException(
"Policy qualifier info set could not be build.", ex, certPath, index);
}
bool match = PkixCertPathValidatorUtilities.ProcessCertD1i(i, policyNodes, pOid, pq);
if (!match)
{
PkixCertPathValidatorUtilities.ProcessCertD1ii(i, policyNodes, pOid, pq);
}
}
}
if (acceptablePolicies.IsEmpty || acceptablePolicies.Contains(Rfc3280CertPathUtilities.ANY_POLICY))
{
acceptablePolicies.Clear();
acceptablePolicies.AddAll(pols);
}
else
{
ISet t1 = new HashSet();
foreach (object o in acceptablePolicies)
{
if (pols.Contains(o))
{
t1.Add(o);
}
}
acceptablePolicies.Clear();
acceptablePolicies.AddAll(t1);
}
//
// (d) (2)
//
if ((inhibitAnyPolicy > 0) || ((i < n) && PkixCertPathValidatorUtilities.IsSelfIssued(cert)))
{
foreach (Asn1Encodable ae in certPolicies)
{
PolicyInformation pInfo = PolicyInformation.GetInstance(ae.ToAsn1Object());
if (Rfc3280CertPathUtilities.ANY_POLICY.Equals(pInfo.PolicyIdentifier.Id))
{
ISet _apq = PkixCertPathValidatorUtilities.GetQualifierSet(pInfo.PolicyQualifiers);
IList _nodes = policyNodes[i - 1];
for (int k = 0; k < _nodes.Count; k++)
{
//.........这里部分代码省略.........
示例2: StepDel
/// <summary>
/// Eliminate ε-rules
/// </summary>
/// <param name="productions"></param>
// TODO: Does not preserve weights
private void StepDel(ISet<Production> productions) {
var nullableProbabilities = GrammarHelpers.GetNullable(productions);
var newRules = new List<Production>();
foreach (var production in productions) {
var toAdd = Nullate(production, nullableProbabilities);
RemoveExtraneousNulls(toAdd);
newRules.AddRange(toAdd);
}
productions.Clear();
productions.UnionWith(newRules);
}
示例3: StepUnit
/// <summary>
/// Eliminate unit rules (e.g., <X> -> <Y>)
/// </summary>
/// <param name="productions"></param>
private void StepUnit(ISet<Production> productions) {
// TODO: maybe we shouldn't allow self loops?
RemoveSelfLoops(productions);
var toRemove = BaseGrammar.RemoveDuplicatesHelper(productions);
foreach (var production in toRemove) {
productions.Remove(production);
}
var finalProductions = RemoveUnits(productions);
productions.Clear();
productions.UnionWith(finalProductions);
}
示例4: StepBin
/// <summary>
/// Eliminate right-hand sides with more than 2 nonterminals
/// </summary>
/// <param name="productions"></param>
private void StepBin(ISet<Production> productions) {
List<Production> finalProductions = new List<Production>();
foreach (var production in productions) {
if (production.Rhs.Count < 3) {
finalProductions.Add(production);
continue;
}
var rhs = production.Rhs;
var curr = production.Lhs;
for (int i = 0; i < rhs.Count - 2; i++) {
var weight = (curr == production.Lhs) ? production.Weight : 1.0;
var left = rhs[i];
var newFresh = GetFresh();
finalProductions.Add(
new Production(curr, new Sentence { left, newFresh }, weight)
);
curr = newFresh;
}
finalProductions.Add(
new Production(curr, new Sentence { rhs[rhs.Count - 2], rhs[rhs.Count - 1] })
);
}
productions.Clear();
productions.UnionWith(finalProductions);
}