本文整理汇总了C#中Comparison类的典型用法代码示例。如果您正苦于以下问题:C# Comparison类的具体用法?C# Comparison怎么用?C# Comparison使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Comparison类属于命名空间,在下文中一共展示了Comparison类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrioritiseOrderBooks
public static void PrioritiseOrderBooks(List<OrderBook.OrderBook> orderBooks,
Comparison<OrderBook.OrderBook> orderBookComparer, //reads as "sort the OrderBooks by orderBookComparer
int dedicatedThreadsPercentage = 10, // the top 10% of the sorted OrderBooks should have dedicated threads,
int threadPooledPercentage = 20) // the next 20% of the OrderBooks use the ThreadPool
// and the remaining 70% will be synchronouss"
{
if (orderBooks == null) throw new ArgumentNullException("orderBooks");
if (orderBookComparer == null) throw new ArgumentNullException("orderBookComparer");
orderBooks.Sort(orderBookComparer);
for (int i = 0; i < orderBooks.Count; ++i)
{
decimal percentageOfBooks = ((i + 1) / (decimal)orderBooks.Count) * 100m;
OrderBook.OrderBook oBook = orderBooks[i];
int limitForThreadPooled = dedicatedThreadsPercentage + threadPooledPercentage;
if (percentageOfBooks <= dedicatedThreadsPercentage && !(oBook.OrderProcessingStrategy is DedicatedThreadsOrderProcessor))
oBook.OrderProcessingStrategy = new DedicatedThreadsOrderProcessor(oBook.BuyOrders, oBook.SellOrders,
oBook.Trades);
else if (percentageOfBooks <= limitForThreadPooled && !(oBook.OrderProcessingStrategy is ThreadPooledOrderProcessor))
oBook.OrderProcessingStrategy = new ThreadPooledOrderProcessor(oBook.BuyOrders, oBook.SellOrders,
oBook.Trades);
else if (!(oBook.OrderProcessingStrategy is SynchronousOrderProcessor))
oBook.OrderProcessingStrategy = new SynchronousOrderProcessor(oBook.BuyOrders, oBook.SellOrders,
oBook.Trades);
}
}
示例2: Filter
/// <summary>
/// Initializes a new instance of the <see cref="DataAccess.Filter"/> class.
/// </summary>
/// <param name="field">Field name for filter</param>
/// <param name="comparator">Comparator operator</param>
/// <param name="value">Value for comparison</param>
public Filter(string field, Comparison comparator, object value)
: this()
{
Field = field;
Comparator = comparator;
Value = value;
}
示例3: Field
public Field(string name, object value, Comparison comparison, Logical? logical)
{
Name = name;
Value = value;
Comparison = comparison;
Logical = logical;
}
示例4: CheckComparison
//
private static void CheckComparison(Comparison comparison, ComparisonResult comparisonResult, string propName, object lValue, object rValue)
{
Assert.AreEqual(comparisonResult, comparison.Result);
Assert.AreEqual(propName, comparison.PropName);
Assert.AreEqual(lValue, comparison.LValue);
Assert.AreEqual(rValue, comparison.RValue);
}
示例5: Sort
public static void Sort(int[][] array, Comparison<int[]> comparison)
{
if (comparison == null)
throw new ArgumentNullException();
SortAdapter comparer = new SortAdapter(comparison);
BubbleSort(array, comparer);
}
示例6: KnowledgeCondition
public KnowledgeCondition(Scope scope, Comparison comparison, string name, object rhs = null)
{
_scope = scope;
_comparison = comparison;
_name = name;
_rhs = rhs;
}
示例7: SelectSort
// Select sort
// The way it's done here is that it creates an entirely new list (sorted) which it then begins to fill with the
// nodes from the original list.
public void SelectSort( Comparison< Drug > UsersDrugComparer )
{
//Create new "sorted" list
DrugList sorted = new DrugList( );
//While there are still nodes in the original list...
while( this.count > 0 )
{
Node previous, minimum, removed;
//Find the smallest node in the original list using the comparison method and return it and the one before it
//NOTE: The comparison method in this case (found in pa4Test.cs) will actually sort it in descending order, but
//this can be easily changed by removing the negative in the return statement in that method
this.FindMinimalNode( out previous, out minimum, UsersDrugComparer );
//Remove that node and store it in the variable "removed"
removed = this.RemoveNode( previous, minimum );
//Insert that node at the end of the sorted list
sorted.InsertNode( removed, sorted.tail, null );
}
this.count = sorted.count;
this.tail = sorted.tail;
this.head = sorted.head;
}
示例8: WhereClause
internal List<SubClause> SubClauses; // Array of SubClause
public WhereClause(string field, Comparison firstCompareOperator, object firstCompareValue)
{
FieldName = field;
ComparisonOperator = firstCompareOperator;
Value = firstCompareValue;
SubClauses = new List<SubClause>();
}
示例9: MatchDescription
public MatchDescription(Card card)
{
this.cardType = card;
this.countSource = CountSource.Always;
this.comparison = Comparison.Equals;
this.countThreshHold = 1;
}
示例10: ANDORWhere
public ANDORWhere(Column column, object value, Comparison comp, bool useOr)
{
_column = column;
_value = value;
_comp = comp;
_useOr = useOr;
}
示例11: Comparator
public Comparator(string name, Comparison<NativeArray> comparison)
{
GCHandle selfHandle = default(GCHandle);
try
{
var utf = Encoding.UTF8.GetBytes(name);
NativeName = Marshal.AllocHGlobal(utf.Length + 1);
Marshal.Copy(utf, 0, NativeName, utf.Length);
Comparison = comparison;
selfHandle = GCHandle.Alloc(this);
Handle = LevelDBInterop.leveldb_comparator_create(
GCHandle.ToIntPtr(selfHandle),
Marshal.GetFunctionPointerForDelegate(Destructor),
Marshal.GetFunctionPointerForDelegate(Compare),
Marshal.GetFunctionPointerForDelegate(GetName));
if (Handle == IntPtr.Zero)
throw new ApplicationException("Failed to initialize LevelDB comparator");
}
catch
{
if (selfHandle != default(GCHandle))
selfHandle.Free();
if (NativeName != IntPtr.Zero)
Marshal.FreeHGlobal(NativeName);
throw;
}
}
示例12: TestDseVersion
/// <summary>
/// Creates the TestDseVersion object
/// </summary>
/// <param name="comparisonOperator">Determines if the DSE version required should be "greater or equals to" = 1, "equals to" = 0, "less than or equal to " = -1</param>
public TestDseVersion(int major, int minor, Comparison comparison = Comparison.GreaterThanOrEqualsTo)
{
Major = major;
Minor = minor;
Build = 0;
Comparison = comparison;
}
示例13: BindingParser
static BindingParser()
{
MemberComparison = OrderByMemberPriority;
DelimeterTokens = new HashSet<TokenType>
{
TokenType.Comma,
TokenType.Eof,
TokenType.Semicolon
};
ResourceTokens = new HashSet<TokenType>
{
TokenType.Dollar,
TokenType.DoubleDollar
};
LiteralConstants = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
TrueLiteral,
FalseLiteral,
NullLiteral
};
LiteralTokens = new HashSet<TokenType>
{
TokenType.IntegerLiteral,
TokenType.RealLiteral,
TokenType.StringLiteral
};
EmptyBindingSourceDelegates = new Func<IDataContext, IObserver>[]
{
BindEmptyPathSource
};
EmptyPathSourceDelegate = context => context.Add(BindingBuilderConstants.Sources, EmptyBindingSourceDelegates);
}
示例14: AddConstraint
private void AddConstraint(string columnName, Comparison comp, object value)
{
Constraint c = new Constraint(ConstraintType.Where, columnName);
if(result.Count > 1)
c = new Constraint(ConstraintType.And, columnName);
//c.ParameterName = columnName;
if(comp == Comparison.StartsWith)
{
value = string.Format("{0}%", value);
comp = Comparison.Like;
}
else if(comp == Comparison.EndsWith)
{
value = string.Format("%{0}", value);
comp = Comparison.Like;
}
c.Comparison = comp;
c.ParameterValue = value;
result.Add(c);
}
示例15: salvaScore_Click
private void salvaScore_Click(object sender, RoutedEventArgs e)
{
List<itemRanking> ranking = new List<itemRanking>();
ranking.Capacity = 3;
itemRanking itemRanking = new itemRanking();
itemRanking.nomeJogador = campoJogador.Text;
itemRanking.pontuacao = this.pontuacao;
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("ranking"))
{
ranking = (List<itemRanking>)settings["ranking"];
ranking.Add(itemRanking);
Comparison<itemRanking> comparador = new Comparison<itemRanking>(itemRanking.comparaPontuacao);
ranking.Sort(comparador);
if (ranking.Count > 3)
{
ranking.RemoveAt(3);
}
}
else
{
ranking.Add(itemRanking);
}
settings["ranking"] = ranking;
settings.Save();
NavigationService.Navigate(new Uri("/Ranking.xaml", UriKind.Relative));
}