本文整理汇总了C#中System.Collections.ArrayList.ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.ElementAt方法的具体用法?C# ArrayList.ElementAt怎么用?C# ArrayList.ElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了ArrayList.ElementAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveDuplicatedDisjuncts
public static void RemoveDuplicatedDisjuncts(ArrayList<ArrayList<QueryToken>> disjuncts)
{
IEqualityComparer<string> tokenComparer = new DefaultTokenComparer(DefaultTokenComparer.Options.ConvertUmlauts | DefaultTokenComparer.Options.RemoveDiacritics);
ArrayList<int> disjunctsToRemove = new ArrayList<int>();
for (int i = 0; i < disjuncts.Count(); ++i)
for (int j = i + 1; j < disjuncts.Count(); ++j)
{
if (ContainsTokenSubset(disjuncts.ElementAt(j), disjuncts.ElementAt(i)))
{
disjunctsToRemove.Add(i);
break;
}
}
disjunctsToRemove.Sort();
disjunctsToRemove.Reverse();
foreach (var toRemove in disjunctsToRemove.Distinct())
disjuncts.RemoveAt(toRemove);
}
示例2: GetSubsets
private static ArrayList<ArrayList<QueryToken>> GetSubsets(ArrayList<QueryToken> array)
{
ArrayList<ArrayList<QueryToken>> subsets = new ArrayList<ArrayList<QueryToken>>();
int count = 1 << array.Count; // 2^n
for (int i = 1; i < count; i++)
{
ArrayList<QueryToken> subsetTerms = new ArrayList<QueryToken>();
BitArray bitArray = new BitArray(BitConverter.GetBytes(i));
for (int bit = 0; bit < bitArray.Count; bit++)
{
if (bitArray[bit])
subsetTerms.Add(array.ElementAt(bit));
}
if (subsetTerms.Count > 0)
subsets.Add(subsetTerms);
Debug.Assert(subsetTerms.Count > 0, "QueryConverterUtils.GetSubsets: subsetTerms.Count shoudln't be 0!");
}
return subsets;
}
示例3: RemoveDisjunctsContainingSubsets
private static void RemoveDisjunctsContainingSubsets(ArrayList<ArrayList<QueryToken>> disjuncts, ArrayList<QueryToken> subset)
{
ArrayList<int> disjunctsToRemove = new ArrayList<int>();
for (int i = 0; i < disjuncts.Count(); ++i)
{
if (ContainsTokenSubset(subset, disjuncts.ElementAt(i)))
disjunctsToRemove.Add(i);
}
disjunctsToRemove.Sort();
disjunctsToRemove.Reverse();
foreach (var toRemove in disjunctsToRemove.Distinct())
{
disjuncts.RemoveAt(toRemove);
}
}
示例4: ElementAtShouldNotAllowIndexOutOfRange
public void ElementAtShouldNotAllowIndexOutOfRange()
{
var target = new ArrayList();
var ex = Assert.Throws<ArgumentOutOfRangeException>( () => target.ElementAt( -1 ) );
Assert.Equal( "index", ex.ParamName );
ex = Assert.Throws<ArgumentOutOfRangeException>( () => target.ElementAt( 1 ) );
Assert.Equal( "index", ex.ParamName );
}