问题列表 - 第217542页

C#将一个单词拆分成字符,然后将每个字母的ASCII码相加得到一个总和

如何将单词拆分为字符然后将所有ASCII码相加以获得整数和?

c#

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

使用私有构造函数静态初始化

在类中,我有一个静态成员,表示该类的单例实例:

class A {
public:
  static const std::shared_ptr<A> INSTANCE;
private:
  A();
};
Run Code Online (Sandbox Code Playgroud)

为了防止更多实例,我将构造函数设为私有.现在我无法初始化静态var,因为初始化程序无法访问私有成员.这是我在.cpp文件中使用的代码:

const std::shared_ptr<A> A::INSTANCE = std::make_shared<A>();
Run Code Online (Sandbox Code Playgroud)

工厂方法也无济于事,因为它也必须是公开的.我还能做些什么来完成这项工作?注意:static get()如果可能的话,我想避免使用典型的方法.

c++

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

Pycharm突然显示"未解决的参考"

我不知道我能做些什么,但是Pycharm现在决定声称它不知道类似的东西,TaggedDocument或者Doc2Vec虽然它在一小时前工作.

在此输入图像描述

这是我的项目结构:

在此输入图像描述

我不记得做任何导致这种情况的事情所以请告诉我如何解决这个问题.

我不知道在项目资源管理器中的外部库中我实际上可以看到它gensim.models.doc2vec实际存在.那么为什么PyCharm仍然在这里抱怨?


在此输入图像描述


更新

我注意到以下内容:在包中gensim.models我看到该文件doc2vec.py未标记为Python文件!请注意右侧没有语法突出显示!奇怪的是,该目录中的所有其他文件实际上都被正确识别!

在此输入图像描述

这些是文件权限 /usr/local/lib/python2.7/dist-packages/gensim/models

drwxr-sr-x 3 root staff   4096 Oct 23  2015 .
drwxr-sr-x 9 root staff   4096 Oct 23  2015 ..
-rw-r--r-- 1 root staff 570651 Oct 23  2015 doc2vec_inner.c
-rw-r--r-- 1 root staff  26872 Oct 23  2015 doc2vec_inner.pyx
-rwxr-xr-x 1 root staff 473658 Oct 23  2015 doc2vec_inner.so
-rw-r--r-- 1 root staff  37304 Oct 23  2015 doc2vec.py
-rw-r--r-- 1 root staff …
Run Code Online (Sandbox Code Playgroud)

python pycharm

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

找不到SecurityMockMvcConfigurers

我正在尝试编写一个Spring安全测试,如http://docs.spring.io/spring-security/site/docs/4.0.x/reference/htmlsingle/#test-mockmvc-setup所述.我需要导入SecurityMockMvcConfigurers为静态导入,但我的IDE找不到该类.

我的pom.xml如下所示:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.M2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

Spring Boot 1.4.0.M2导入Spring Security 4.0.4.RELEASE.我在这个版本中找不到这个类.我需要哪种额外的依赖?或者我没有考虑过什么呢?

java spring spring-security spring-boot

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

单个读取器多个写入器与pthreads和锁定,没有提升

考虑下一段代码.

#include <iostream>
#include <vector>
#include <map>

using namespace std;

map<pthread_t,vector<int>> map_vec;
vector<pair<pthread_t ,int>> how_much_and_where;

pthread_cond_t CV = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

void* writer(void* args)
{
    while(*some condition*)
    {
        int howMuchPush = (rand() % 5) + 1;
        for (int i = 0; i < howMuchPush; ++i)
        {
            // WRITE
            map_vec[pthread_self()].push_back(rand() % 10);
        }

        how_much_and_where.push_back(make_pair(pthread_self(), howMuchPush));
        // Wake up the reader - there's something to read.
        pthread_cond_signal(&CV);
    }

    cout << "writer thread: " <<  pthread_self()  << endl;
    return nullptr;
} …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading pthreads producer-consumer

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

如何在SQL中按列名检查单元格是否为空?

我试图在SQL中构建一个存储过程.

我有以下语法:

CREATE PROCEDURE [dbo].[getAllCitizens]
    @NoInfo as nvarchar(50) = "No contact information inserted."
AS
BEGIN
    SET NOCOUNT ON;
    IF ctznPhone != null
        BEGIN
            SELECT ctznTz, ctznLname, ctznFname, ctznPhone
            FROM tblCitizens
            Where ctznLivestat=1
        END
    ELSE
        BEGIN
            IF ctznEml != null
                BEGIN
                SELECT ctznTz, ctznLname, ctznFname, ctznEml
                FROM tblCitizens
                Where ctznLivestat=1
                END
            ELSE
                BEGIN
                    SELECT ctznTz, ctznLname, ctznFname, @NoInfo
                    FROM tblCitizens
                    Where ctznLivestat=1
                END
        END
END
Run Code Online (Sandbox Code Playgroud)

我如何告诉列ctznPhone和哪个表的过程ctznEml

我曾尝试dbo.tablename.columname和各种尝试用()[],但似乎并没有工作.

最终,此过程将由C#datareader调用.我要做的是构建一个过程,当被调用时,将从一行返回所选单元格,具体取决于特定单元格中的信息:

  • 如果ctznPhone不为null,那么我想得到它. …

c# sql t-sql sql-server stored-procedures

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

如何在python中将字符串值转换为int值

我想在python中制作一个二十一点游戏.就像一个7s的值是7但是,一个jacks值是10所以:

cards = ['ace','king','queen'....'3','2'

firstCard = random.choice(cards)

secondCard = random.choice(cards); remove.cards(firstCard)

print(int(firstCard) + int(secondCard))
Run Code Online (Sandbox Code Playgroud)

适用于数字

我怎么能为国王或王牌做到这一点......

python python-3.x

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

在ScalaJs sbt构建中,使用webjars而不是npm或bower与'提供'是否有任何优势?

几个月前,当我第一次发现webJars时,我非常怀疑,鉴于某些构建/构建系统的巨大复杂性以及js文件发布的频率,它将成为处理客户端依赖关系的可行方式.第二个问题当然不是很有根据,但是我在第一个问题上得到了证明,在花了差不多36个小时之后,现在徒劳地试图让10个scss/css/less类型的webJars和8个JS webJars生活在一个jsDependencies屋檐下.

我发现当你达到JS依赖3,4或5时,你开始进入一个荒谬的timekill循环:

1."哦,没有!fastOptJS失败了,因为有一些随机文件也被命名为webjar中的依赖项!"

[trace] Stack trace suppressed: run last client/compile:resolvedJSDependencies for the full output.
[error] (client/compile:resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries could not be resolved:
[error] - Ambiguous reference to a JS library: bootstrap.min.js
[error]   Possible paths found on the classpath:
[error]   - META-INF/resources/webjars/bootstrap/3.3.6/js/bootstrap.min.js
[error]   - META-INF/resources/webjars/bootstrap3-dialog/1.34.4/examples/assets/bootstrap/js/bootstrap.min.js
[error]   originating from: client:compile, client:compile, client:compile, client:compile
[error] - Ambiguous reference to a JS library: bootstrap.js
[error]   Possible paths found on the classpath:
[error]   - …
Run Code Online (Sandbox Code Playgroud)

sbt node.js scala.js sbt-web

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

你可以自定义代码折叠吗?

是否可以自定义代码折叠在Visual Studio代码中的工作方式?

我使用了一种在各种不同文档类型中定义代码区域的通用模式.

  • 因此,对于XML,我用<!-- #region -->和包装文本的部分<!-- #endregion -->

  • 对于c#,我#region用来#endregion,

  • 对于TypeScript/Javascript,我使用/* #region *//* #endregion */.

在完整的Visual Studio(不是VS代码)中,我有一个自定义扩展,可以跨文档类型窥探模式,并根据它创建折叠,允许我创建整洁的自定义文档轮廓.我想在Visual Studio Code中使用相同的模式.是否可以创建一个自定义VS代码扩展来检测这些注释模式,并以某种方式根据模式标记折叠?

visual-studio-code vscode-extensions

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

无法在 Ubuntu 16.04 上安装 Chrome

从 Google 网站加载 Chrome 的 .deb 包。尝试从 GUI 安装时安装不起作用。那是怎么回事?

google-chrome ubuntu-16.04

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