`

Use of Interface to express constraint

    博客分类:
  • C#
阅读更多

let's first see some live example of how to use the Interfaces to express the idea of something abstract.

 

 

First of all, let 's see the Ikey interface and some of the other interfaces.

 

 

    public interface IKey<TEntity> : IKey, IQuery<TEntity>
    {
    }

    public interface IKey : IEquatable<IKey>
    {
    }

    public interface IQuery<TEntity> : IEquatable<IQuery<TEntity>>
    {
    }

 

 

So let's break down.

 

First of all, the IKey interface is inherit from IEquatable<IKey>, which implies that the IKey instance should be able to compare with another instance of IKey (which is the type parameter of base IEquatable).

 

then there is the Generic version of the interface, which is IKey<TEntity>; THis interface will inherit the IKey interface, which basically means that any Generic version of the Ikey interface is also a IKey and should be able to compare with any other IKey<TEntity> instance (the TEntity type parameter can can NOT different); --- or in other word, a Generic Form interface is also a type of the non-generic form of interfaces.

 

Last, let's see the IQuery interface, this interface is nearly the same as the IKey (non-generic form interface) but IQuery interface is a generic version of interface.

 

 

 

so by combining the interface together, it means that 

 

 

public interface IKey<TEntity> : IKey, IQuery<TEntity>

 

IKey<TEntity> is the an interface that can compare with IKey<AnotherTEntity> or can compare with Ikey or can compare with Key<TEntity> (the same type parameter).

 

Herei s one thought, why not to have the following signature?

 

 

public interface IKey<TEntity> : IKey, IEquatable<TEntity>
 

TODO:

 

add some concrete class that implements those inerfaces.

 

 

 

分享到:
评论

相关推荐

    Handbook of Parallel Constraint Reasoning

    《Handbook of Parallel Constraint Reasoning》是一本关于并行约束推理的工具书,由Youssef Hamadi和Lakhdar Sais编辑,于2018年由Springer International Publishing AG出版。本书的关键词包括“并行推理”、...

    principles of constraint programming.ppt

    在这个名为"principles of constraint programming.ppt"的演示文稿中,我们将会深入探讨约束编程的基本概念、核心原理以及在实际应用中的价值。 首先,我们要理解什么是约束编程。约束编程是建立在一组变量和这些...

    Principles of constraint programming

    书中详细阐述了约束编程的核心框架,包括预处理(Preprocess)、幸福状态(Happy)、原子性(Atomic)、分割(Split)、按情况推进(Proceed by Cases)以及约束传播(Constraint Propagation)。其中,约束传播算法...

    Ebook - Constraint Logic Programming using ECLiPSe

    This book has a two-fold purpose. It’s an introduction to constraint programming... which, ultimately allows the reader to better understand the proper use of constraints in solving real-world problems.

    Handbook of constraint programming

    动态规划 Constraits in Procedural and Concurrent Languages 限制编程人员必备的手册,很有用的。用于算法优化

    Grammatical theory From transformational grammar to constraint-based approaches

    Grammatical theory From transformational grammar to constraint-based approaches Stefan Müller 2017新书,欢迎对形式语言学,自然语言处理等领域感兴趣读者下载。

    Object Constraint Language, The: Getting Your Models Ready for MDA, Second

    The authors' pragmatic approach and illustrative use of examples will help application developers come quickly up to speed with this important object-modeling method--and will serve as a ready ...

    Handbook of Constraint Programming (Rossi F.&Co(eds))

    在约束规划中,CSP(Constraint Satisfaction Problem)是核心概念。CSP通常由三个关键组成部分构成:变量、值域和约束。变量代表问题中的决策元素,值域是变量可能取的值的集合,而约束则定义了变量之间的关系,...

    Principles and Practice of Constraint Programming

    约束编程(Constraint Programming,CP)是一种强大的问题解决方法,它使用约束来表示问题的约束条件,从而限制可能的解决方案。在约束编程中,问题首先被建模为变量的集合,这些变量必须满足一定的约束条件。通过...

    Existence of solution to a class of stochastic Riccati equations with constraint

    一类随机$Riccati$方程的解的存在性研究,韩月才,许洁,本文研究了一类满足一定限制条件的随机$Riccati$方程解的存在性。随机$Riccati$方程是个矩阵值高阶非线性倒向随机微分方程,并满足一个�

    Analysis of the constraint relation between ground and selfadaptive mobile

    研究者对TWT单元的结构进行了深入分析,提出了“MGCR模型”(Mobile Mechanism-Ground Constraint Relation model),这一模型是用来研究机器人如何在非结构化环境中移动的数学模型。MGCR模型的建立,能够帮助我们更...

    Handbook of Constraint Programming

    David Cohen和Peter Jeavons的章节“Complexity of Constraint Languages”可能探讨了约束语言的复杂性理论,包括基本定义、示例、代数理论的发展、应用以及在无限集合上的约束语言。约束语言的复杂性通常取决于它们...

    Integration of AI and OR Techniques in Constraint Programming

    优化方面的书籍,用cplex12.5讲解

    A Fast and Simple Algorithm for Bounds Consistency of the AllDifferent Constraint

    本文提出了一种针对全不同约束(AllDifferent Constraint)的快速且简单的界传播一致性算法。该算法不仅保持了现有最佳算法的最坏情况行为,而且在实践中表现得更为高效。通过多种基准测试与随机问题实例的对比实验...

    constraint-layout-solver-1.0.0-alpha1

    Failed to resolve: com.android.support.constraint:constraint-layout:1.0.0-alpha1

    Signal Constraint使用方法简介

    通过对Simulink模型添加信号约束模块(Signal Constraint block)可以优化已知输入的模型响应。Simulink设计优化软件(Simulink Design Optimization software)通过调整模型的参数来满足指定的约束,其中包括信号...

    handbook of Constraint Programming

    《约束编程手册》是人工智能领域的一本重要参考书,它主要关注的是约束满足问题(Constraint Satisfaction Problem, CSP)。CSP 是一种模型化和求解复杂问题的方法,广泛应用于规划、调度、配置、优化等多个领域。在...

    Introduction_to_Optimum_Design.pdf

    - **Postoptimality Analysis:** Analyzes the sensitivity of the solution to changes in constraint limits and cost function scaling, providing insights into the robustness of the solution. ### Chapter ...

Global site tag (gtag.js) - Google Analytics