constraints

Generic method type and method parameter does not match [closed]

旧街凉风 提交于 2020-01-04 05:27:45
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I just stumbled over that and I can't really explain that. Say I have that code: public interface IFeature { } public class FeatureA : IFeature { } class Program { static void Main(string[] args) { var feature = new FeatureA(); Load(feature); } private static void Load(IFeature featureDefinition) { Activate

How to fit a circle to a set of points with a constrained radius?

一曲冷凌霜 提交于 2020-01-04 05:20:43
问题 I have a set of points that represent a small arc of a circle. The current code fits a circle to these points using linear least-squares: void fit_circle(const std::vector<cv::Point2d> &pnts,cv::Point2d &centre, double &radius) { int cols = 3; cv::Mat X( static_cast<int>(pnts.size()), cols, CV_64F ); cv::Mat Y( static_cast<int>(pnts.size()), 1, CV_64F ); cv::Mat C; if (int(pnts.size()) >= 3 ) { for (size_t i = 0; i < pnts.size(); i++) { X.at<double>(static_cast<int>(i),0) = 2 * pnts[i].x; X

Oracle unique constraint and primary key not null

北城余情 提交于 2020-01-04 04:24:16
问题 Can a table have a primary key attribute and a unique constraint to another attribute? I have the following CREATE TABLE BRANCH( BRA_CODE NUMBER NOT NULL PRIMARY KEY, BRA_NAME VARCHAR(15), BRA_ADDR VARCHAR(30), CITY_ID NUMBER); and im trying to add ALTER TABLE BRANCH ADD CONSTRAINT UNIQUE_BRANCH_NAME UNIQUE (BRA_NAME); and i get the following error; ERROR at line 1: ORA-02261: such unique or primary key already exists in the table 回答1: Q: Can a table have a primary key attribute and a unique

SQL - How do I delete two entities referencing each other

烈酒焚心 提交于 2020-01-04 03:51:09
问题 So I have two entities referencing each other, parent , child . child must be deleted if parent is deleted, but cannot be deleted while there's still a parent referencing it. These are the two constraints I've been given: ALTER TABLE public.parent ADD CONSTRAINT parent__child_id__fk FOREIGN KEY (child_id) REFERENCES child(id) ON DELETE CASCADE ; ALTER TABLE public.child ADD CONSTRAINT child__parent_code__id__fk FOREIGN KEY (parent_code, id) REFERENCES parent(code, child_id) ON UPDATE CASCADE

Need to add constraint: date plus 10 days

做~自己de王妃 提交于 2020-01-04 03:24:08
问题 I'm trying to add a constraint to a table so that it displays one of the columns as the current date plus 10 days. Here's what I've tried so far (I'm very new to SQL): ALTER TABLE orders ADD CONSTRAINT default_date DEFAULT DATEADD (DAY,10,required_date) FOR required_date Halp! Edit: I've also tried this now: ALTER TABLE orders ALTER COLUMN required_date ADD CONSTRAINT required_date_plus_ten DEFAULT DATEADD (DAY,10,required_date) Edit: Thanks to ypercube & my classmate. The final code is:

Recursive constraints: What does DBase<T> : where T : DBase<T> mean?

試著忘記壹切 提交于 2020-01-03 20:57:13
问题 I thought I understood generic constraints until I ran across this. public class DBase<T> : DbContext, IDisposable where T : DBase<T> How can T be DBase<T> ? And if it can, what does it mean? This code compiles and runs fine. I'm not fixing a problem. I just don't understand it. It is used here public class ChildDb : DBase<ChildDb> Which, again, doesn't compute for me. It passes itself as a type parameter? 回答1: How can T be DBase<T> ? There is no limitation that prevents a Generic Parameter

C#: Enum.IsDefined on combined flags

[亡魂溺海] 提交于 2020-01-03 07:24:26
问题 I have this enum: [Flags] public enum ExportFormat { None = 0, Csv = 1, Tsv = 2, Excel = 4, All = Excel | Csv | Tsv } I am trying to make a wrapper on this (or any, really) enum which notifies on change. Currently it looks like this: public class NotifyingEnum<T> : INotifyPropertyChanged where T : struct { private T value; public event PropertyChangedEventHandler PropertyChanged; public NotifyingEnum() { if (!typeof (T).IsEnum) throw new ArgumentException("Type T must be an Enum"); } public T

Hibernate: constraintName is null in MySQL

时光怂恿深爱的人放手 提交于 2020-01-02 10:16:27
问题 I have a code using JPA with Hibernate 3.3.x. This Java code can be used with schemas stored either on Oracle 10g or MySQL 5.1.x. Tables are defined with constraints to define unique records. When a constraint violation occurs, I want to retrieve the constraint name from the exception. With Oracle, the constraint name is properly retrieved. With MySQL, the constraint name is NULL . Any idea how to get the constraint name with MySQL? Thanks Said 回答1: I've come up with the following solution:

I don't know hot to plot this nonlp's feasible reagion in matlab

非 Y 不嫁゛ 提交于 2020-01-02 07:40:16
问题 I searched and watched how to plot the 3 dimensions of nonlp program's but I still don't know how to plot these constraints. x^2+y^2+z^2=1 x>=2*y 2*y>=3*z x>=3*z I programmed like this but it doesn't work and I think this is wrong program for upper constraints. func1 = @(x,y,z) sqrt(1-x.^2-y.^2); func2 = @(x,y,z) max(x-2*y,0); func3 = @(x,z) max(x-3*z,0); ezsurf(func1,[0 1 0 1]); hold on; ezsurf(func2,[0 1 0 1]); hold on; ezsurf(func3,[0 1 0 1]); axis([0 1 0 1 0 1]); 回答1: A way of doing that

How to constrain UIScrollView to only zoom vertically?

谁说我不能喝 提交于 2020-01-02 06:51:52
问题 I have a UIScrollView which I'm using to represent an axis on a graph. I'd like the user to be able to zoom in on the axis using the usual pinch motion, but for it to only scale in the vertical direction, not horizontally. My question is similar to this one, but I've tried the solution suggested there (overriding the subview's SetTransform method so that it ignores scaling in one direction) and it works perfectly when constraining scaling horizontally, but not vertically. When I try