本文整理汇总了C#中Comparison类的典型用法代码示例。如果您正苦于以下问题:C# Comparison类的具体用法?C# Comparison怎么用?C# Comparison使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Comparison类属于命名空间,在下文中一共展示了Comparison类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:loning,项目名称:OrderMatchingEngine,代码行数:28,代码来源:Market.cs
示例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;
}
开发者ID:CIR2000,项目名称:DataAccess,代码行数:13,代码来源:Filters.cs
示例3: Field
public Field(string name, object value, Comparison comparison, Logical? logical)
{
Name = name;
Value = value;
Comparison = comparison;
Logical = logical;
}
开发者ID:jroliveira,项目名称:restful-query-filter,代码行数:7,代码来源:Field.cs
示例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);
}
开发者ID:njmube,项目名称:public,代码行数:8,代码来源:AcceptanceTests.cs
示例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);
}
开发者ID:AlexanderChechet,项目名称:ASP.NET.AlexanderChechet.Day6,代码行数:7,代码来源:SorterWithAdapter.cs
示例6: KnowledgeCondition
public KnowledgeCondition(Scope scope, Comparison comparison, string name, object rhs = null)
{
_scope = scope;
_comparison = comparison;
_name = name;
_rhs = rhs;
}
开发者ID:rtaylornc,项目名称:IntelliMediaCore,代码行数:7,代码来源:KnowledgeCondition.cs
示例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;
}
开发者ID:Lucasvdm,项目名称:BME121CSharpPrograms,代码行数:29,代码来源:DrugList.cs
示例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>();
}
开发者ID:alexrigin,项目名称:HMS2,代码行数:9,代码来源:Clauses.cs
示例9: MatchDescription
public MatchDescription(Card card)
{
this.cardType = card;
this.countSource = CountSource.Always;
this.comparison = Comparison.Equals;
this.countThreshHold = 1;
}
开发者ID:NathanTeeuwen,项目名称:Dominulator,代码行数:7,代码来源:MatchDescription.cs
示例10: ANDORWhere
public ANDORWhere(Column column, object value, Comparison comp, bool useOr)
{
_column = column;
_value = value;
_comp = comp;
_useOr = useOr;
}
开发者ID:chartek,项目名称:graffiticms,代码行数:7,代码来源:ANDORWhere.cs
示例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;
}
}
开发者ID:qcjxberin,项目名称:CacheDB,代码行数:30,代码来源:Comparator.cs
示例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;
}
开发者ID:datastax,项目名称:csharp-driver-dse,代码行数:11,代码来源:TestDseVersion.cs
示例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);
}
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:32,代码来源:BindingParser.cs
示例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);
}
开发者ID:6nop,项目名称:SubSonic-3.0,代码行数:25,代码来源:ExpressionParser.cs
示例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));
}
开发者ID:enilapb,项目名称:wp7,代码行数:30,代码来源:SalvaJogo.xaml.cs
示例16: Sort
public void Sort (Comparison<ICompletionData> comparison)
{
lock (sortedList) {
sortedList.Sort (comparison);
sorted = true;
}
}
开发者ID:DinrusGroup,项目名称:Mono-D,代码行数:7,代码来源:DCompletionDataList.cs
示例17: KeyCatalogFactory
public KeyCatalogFactory(Func<KeyCatalog, string> formatter,
Comparison<KeyCatalog> nameSorter)
: this()
{
ToStringFormatter = formatter;
NameSorter = nameSorter;
}
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:7,代码来源:KeyCatalogFactory.cs
示例18: DepthStencilState
internal DepthStencilState(Device device, DepthStencilStateDescription description)
: base(device)
{
_description = description;
_isDepthEnabled = description.IsDepthEnabled;
_depthComparison = description.DepthComparison;
}
开发者ID:modulexcite,项目名称:rasterizr,代码行数:7,代码来源:DepthStencilState.cs
示例19: DepthStencilState
public DepthStencilState(bool depthEnabled, bool stencilEnabled, Comparison depthComparison,
Comparison frontFaceComparison, StencilOperation frontFaceDepthFailOp, StencilOperation frontFaceFailOp, StencilOperation frontFacePassOp,
Comparison backFaceComparison, StencilOperation backFaceDepthFailOp, StencilOperation backFaceFailOp, StencilOperation backFacePassOp)
{
DepthStencilStateDescription desc = new DepthStencilStateDescription()
{
IsDepthEnabled = depthEnabled,
IsStencilEnabled = stencilEnabled,
DepthWriteMask = SharpDX.Direct3D11.DepthWriteMask.All,
FrontFace = new DepthStencilOperationDescription()
{
Comparison = frontFaceComparison,
DepthFailOperation = frontFaceDepthFailOp,
FailOperation = frontFaceFailOp,
PassOperation = frontFacePassOp
},
BackFace = new DepthStencilOperationDescription()
{
Comparison = backFaceComparison,
DepthFailOperation = backFaceDepthFailOp,
FailOperation = backFaceFailOp,
PassOperation = backFacePassOp
},
DepthComparison = depthComparison
};
NativeDepthStencilState = new SharpDX.Direct3D11.DepthStencilState(GraphicManager.Device, desc);
}
开发者ID:bgarate,项目名称:SynergyEngine,代码行数:30,代码来源:DepthStencilState.cs
示例20: ModelClientValidationRequiredIfRule
public ModelClientValidationRequiredIfRule(string errorMessage, string otherProperty, Comparison comparison, object value, ModelMetadata metadata, ControllerContext context)
{
ErrorMessage = errorMessage;
ValidationType = "requiredif";
ValidationParameters.Add("other", BuildDependentPropertyId(metadata, context as ViewContext, otherProperty));
ValidationParameters.Add("comp", comparison.ToString().ToLower());
ValidationParameters.Add("value", value.ToString().ToLower());
}
开发者ID:elizabeth-young,项目名称:Common,代码行数:8,代码来源:RequiredIfAttribute.cs
注:本文中的Comparison类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论