问题列表 - 第122109页

方根与巴比伦或苍鹭的方法?

我在java中实现了Babylonian/Heron的方法,以获得基于维基百科信息的数字的平方根

目前我有:

public static void main(String[] args) {
    System.out.println(Sqrt.sqrt1(8));
    //System.out.println(Sqrt.sqrt2(8));   //Infinite loop
    System.out.println(Sqrt.sqrt3(8));
    System.out.println(Sqrt.sqrt4(8));
}

static float sqrt1(float x) {
    float b = 0, h = x;

    while (b != h) {
        b = (h + b) / 2;
        h = x / b;
    }
    return b;
}

static double sqrt2(double x) {
    double b = x, h = 0;

    while (b != h) {
        b = (h + b) / 2;
        h = x / b;
    } …
Run Code Online (Sandbox Code Playgroud)

java algorithm math square-root

1
推荐指数
1
解决办法
4116
查看次数

弱实体可以有多个可识别的强实体吗?

数据库中的弱实体可以有多个可识别的强实体吗?

弱实体的主键将是标识键(在弱实体中作为外键存在)的主键的总和。

这样的设计意味着什么?

database entity

5
推荐指数
1
解决办法
1万
查看次数

"virtual void IBase :: Foo"和"virtual void Foo"之间有什么区别?

我使用了VisualAssistX Implement Virtual Methods选项,它生成了:

class Base: public IBase
{
public:
    Base(void);
    ~Base(void);
    virtual void IBase::Foo();
Run Code Online (Sandbox Code Playgroud)

我注意到我可以省略IBase并编程仍然编译如下:

    virtual void Foo();
Run Code Online (Sandbox Code Playgroud)

如果这是相同的代码?为什么VisualAssistX会插入IBase::?是否只是提高可读性的"代码风格"?

谢谢

c++ visual-c++

5
推荐指数
1
解决办法
178
查看次数

如何将Cloud Endpoints生成的sources.jar库移动到Android项目中

Google Plugin for Eclipse包含一个自动生成云端点客户端库的工具.但似乎没有一种简单的方法可以将生成的source.jar文件移动到您的Android源代码中.

文档https://developers.google.com/appengine/docs/java/endpoints/consume_android

端点生成会生成源jar文件.将此jar文件的内容添加到Android项目中.

似乎不可能将source.jar文件放入Android/lib或/ libs,因为源是.java而不是.class形式.所以我只是手动复制GPE生成的源代码(它们放在AppEngine项目的endpoints-lib文件夹中).这可能非常麻烦,尤其是当您有多个端点并经常进行编辑时.

另请参阅将Android应用程序连接到Google Cloud Endpoints时出错:找不到类

有没有人知道在Android项目中直接实际使用sources.jar文件的方法?谢谢.

android google-cloud-endpoints

4
推荐指数
1
解决办法
2071
查看次数

使用WCF传输子类

使用WCF传输子类时遇到一些问题.我想创建一个通用的"反馈"类,并从反馈中继承:Succes-class和Failure-class(失败有错误代码和描述).这应该使客户端能够执行以下操作:

If (myWCFclient.authenticate(user, password) is Succes)
{
..
}
Run Code Online (Sandbox Code Playgroud)

在我的WCF datacontracts中,我这样定义:

[DataContract]
public class Feedback : IFeedback
{ 
}

[DataContract]
public class Succes : Feedback
{
}

[DataContract]
public class Failure : Feedback
{
    [DataMember]
    public int errorCode { get; set; }
    [DataMember]
    public String description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

这很有效,我的运营合同如下:

[OperationContract]
Feedback Authenticate(String email, String password);
Run Code Online (Sandbox Code Playgroud)

但是在我的"客户端"应用程序中,我收到了这些课程,我只发现"反馈"作为一个类,"Succes"和"Failure"无处可寻.

在此输入图像描述

有谁知道我做错了什么?我应该在我的DataContracts中定义那些不同的"Succes"和"Failure"类,因为它们是"反馈"的子类吗?

提前致谢.

c# wcf inheritance class

0
推荐指数
1
解决办法
591
查看次数

从另一个表达式构建索引表达式

脚本

public class Element {
   public int Id {get;set;}
}

public class ViewModel {
   public IList<Element> Elements{get;set;}
}
Run Code Online (Sandbox Code Playgroud)

我有一个类型参数的方法Expression<Func<Element, int>>,看起来像m => m.Id

我想改造

m => m.Id (其中m是元素)

x => x.Elements[0].Id 其中x是ViewModel,0是"index"参数

我现在拥有的(当然是通用的,为了清晰起见我删除了通用部分)

public static class Helpers {
    public static Expression<Func<ViewModel, int>> BuildExpressionArrayFromExpression(
                this Expression<Func<Element, int>> expression,
                ViewModel model,
                int index = 0, 
                string bindingPropertyName = "Elements"//the name of the "List" property in ViewModel class
                ) 
    {
       var parameter = Expression.Parameter(typeof(ViewModel), "x");
       var viewModelProperty = model.GetType().GetProperty(bindingPropertyName);
       Expression …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc lambda expression-trees

1
推荐指数
1
解决办法
1538
查看次数

'gradle eclipse'之后Spring项目中的空验证消息

从使用Maven构建Spring项目迁移到使用gradle构建它之后,我发现了奇怪的空验证错误.

我注意到该路径src/main/webapp/WEB-INF/classes位于Web App Libraries构建路径组下,但是使用Maven-import配置它只是在src目录中.

使用gradle cleanEclipse,清爽和结算项目,也没有删除所有.metadata,.settings,bin,.classpath,.project目录没有帮助.

除了WAR文件建立得很好.

组态:

//----------------------------------------------------------------------------
//                        SERVER'S TASKS' CONFIGURATION
//----------------------------------------------------------------------------

configure(serverProjects) {
    apply plugin : 'war'
    apply plugin : 'eclipse-wtp'

    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

project(':Server') {
    war {
        destinationDir serverDir
    }
}

...

//----------------------------------------------------------------------------
//                      SERVER'S PROJECTS' CONFIGURATION
//----------------------------------------------------------------------------

project(':Server') {
    eclipse {    
        project {
            natures "com.springsource.sts.gradle.core.nature"
        }

        classpath {
            containers "com.springsource.sts.gradle.classpathcontainer"
        }
    }
}

...

//---------------------------------------------------------------------------- …
Run Code Online (Sandbox Code Playgroud)

eclipse spring war gradle

1
推荐指数
1
解决办法
3274
查看次数

jQuery插件创作

知道为什么这个基本的例子不起作用?

http://jsfiddle.net/Kq6pz/

(function( $ ){

  $.fn.testPlugin = function( options ) {  
        alert('hi');
  };
})( jQuery );

$.testPlugin();
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-plugins

2
推荐指数
1
解决办法
214
查看次数

为什么JDBC代码中存在双重问号

我正在使用PHP将JDBC sql语句转换为ODBC/DB2.我遇到了令我困惑的以下条款.

WHERE phid = ??id
Run Code Online (Sandbox Code Playgroud)

我的第一直觉是它是为准备好的陈述,但现在我不太确定.这是一个JSP/JDBC的东西吗?谷歌/堆栈没有发现任何东西.

java sql jdbc

7
推荐指数
1
解决办法
351
查看次数

AzureWebsites上的SignalR CryptographicException

我使用部署在Azure WebSites中的SignalR获得了此异常.它在调试环境中工作正常.它是SignalR 1.0.1,我使用.NET MVC和WebApi

The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may …
Run Code Online (Sandbox Code Playgroud)

azure signalr asp.net-web-api azure-web-sites signalr-hub

3
推荐指数
1
解决办法
1789
查看次数