RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

全部问题

Martin Hope
Sirop4ik
Asked: 2020-12-15 21:51:19 +0000 UTC

如何在 git 分支中设置推送限制?

  • 10

如何让自己成为 git 中的分支管理员?

我们有一个人在做合并和推送到主分支,我们要确保只有他有机会推送到主分支,其他人只能从中拉取。

如何在 git 中实现这一点?

重要的

我们有自己的服务器端,我们不使用gitlab,github等等。

我知道你可以在钩子的帮助下以某种方式做到这一点......

有例子吗?教程

git
  • 2 个回答
  • 10 Views
Martin Hope
Jekyll Hyde
Asked: 2020-12-14 12:01:40 +0000 UTC

元函数,用于确定模板中给定类型的函子特化的存在

  • 10

元函数接受要在模板中检查的类型。如果在 Method<given_type> 上定义了括号运算符,则元函数必须返回 true。否则为假。

#include <iostream>
#include <functional>

template<typename T>
struct Method {};

template<>
struct Method<int> {
    int operator()() { return 1; }
};

template<class T>
struct is_brackets_op_defined {
  static void Check(...);

  template<typename C>
  static decltype(Method<C>::operator()) Check(const C&);

  using type = decltype(Check(
    std::declval< Method<T> >()  
  ));

  constexpr static bool value =  
    !std::is_same<void, type>();
};

int main() {
    std::cout << is_brackets_op_defined<float>::value << std::endl;
}

即使存在特化,我的实现也总是返回 false(此处为 int)

std::cout << is_brackets_op_defined<float>::value // false
std::cout << is_brackets_op_defined<int  >::value // false
c++
  • 3 个回答
  • 10 Views
Martin Hope
Teemitze
Asked: 2020-12-12 14:54:06 +0000 UTC

Java中的DTO是什么?

  • 10

您能否使用简单的 JAVA 代码示例来解释 DTO 是什么?为什么需要这个?

这段代码会是 DTO 吗?有两个类客户和银行

顾客

    import java.sql.Date;

class Customer {
    private String first_name;
    private String last_name;
    private String gedner;
    private Date age;
    private String address;


    Customer(String first_name, String last_name, String gedner, Date age, String address) {
        this.first_name = first_name;
        this.last_name = last_name;
        this.gedner = gedner;
        this.age = age;
        this.address = address;
    }

    public String getLast_name() {
        return last_name;
    }

    public String getFirst_name() {
        return first_name;
    }

    public String getGedner() {
        return gedner;
    }

    public Date getAge() {
        return age;
    }

    public String getAddress() {
        return address;
    }
}

银行

import java.sql.*;
import java.util.Scanner;


public class Bank {
    private static final String URL = "jdbc:mysql://localhost/bank?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
    private static final String USER = "root";
    private static final String PASSWORD = "root";

    Connection connection = null;
    PreparedStatement preparedStatement = null;
    Scanner in = new Scanner(System.in);

    public void connect() {
        try {
            connection = DriverManager.getConnection(URL, USER, PASSWORD);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    Customer readCustomer() {
        Customer customer = null;
        try {
            preparedStatement = connection.prepareStatement("SELECT * FROM customers WHERE id_customer = ?");
            System.out.print("Введите id пользователя: ");
            preparedStatement.setInt(1, Integer.parseInt(in.next()));
            preparedStatement.execute();
            ResultSet rs = preparedStatement.executeQuery();
            String first_name = rs.getString("first_name");
            String last_name = rs.getString("last_name");
            String gender = rs.getString("gender");
            Date age = rs.getDate("age");
            String address = rs.getString("address");
            customer = new Customer(first_name, last_name, gender, age, address);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                preparedStatement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return customer;
    }
}

在 read 方法中,我将 ResultSet 变成了一个客户对象。这是DTO吗?

java
  • 1 个回答
  • 10 Views
Martin Hope
Петровченко Иван
Asked: 2020-11-11 13:32:19 +0000 UTC

为什么在这种情况下创建一个构造函数并在其中指定 throws?

  • 10

为什么要在方法签名中写public static void main操作符throws,也就是这样:

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class Test {
    public static void main(String[] args) throws FileNotFoundException {
        FileInputStream fileInputStream = new FileInputStream("path");
    }
}

如果课程没有public static void main,我会这样写:

import java.io.FileInputStream;

public class Excep {
    FileInputStream fileInputStream = new FileInputStream("path");
}

然后 IDEA 建议您需要在构造中try, catch或使用运算符来处理它throws。我按照 IDEA 对操作员的建议做了throws:

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class Excep {
    FileInputStream fileInputStream = new FileInputStream("path");

    public Excep() throws FileNotFoundException {
    }
}

为什么要在这里创建构造函数,为什么要为它编写运算符throws?

java
  • 2 个回答
  • 10 Views
Martin Hope
Crux Commissa
Asked: 2020-10-11 17:02:08 +0000 UTC

什么可以比数学 sqrt 更快?

  • 10

我有一个任务:我需要尽快找到几万亿个整数的整数平方根个数,不超过100,000^2 。 简单地说:

100 = 10^2 - 适合

3 = 不适合

28 = 不适合

49 = 7^2 - 适合

...

等等

作为任务的一部分,我使用 openMP 指令在处理器内核之间平均分配线程,但即使在这种情况下,程序执行速度也不太适合我。我目前使用的结构是这样的:

int y = sqrt(x);
if (y==int(y))
  i++;

我尝试使用 SET 查找,知道我的数字永远不会超过100,000^2

set<int> mySet;

for (int j = 1; j <= 100001; j++) 
    mySet.insert(j*j);

if (mySet.find(x) != mySet.end()) 
  i++;

但事实证明,这种方法比通常的平方根计算要慢很多倍。告诉我,是否有可能使用语言工具以某种方式加速一次迭代的执行,或者用更快的方法替换根下的计算?我会很高兴任何提示!

c++
  • 5 个回答
  • 10 Views
上一页
下一页

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5