如何让自己成为 git 中的分支管理员?
我们有一个人在做合并和推送到主分支,我们要确保只有他有机会推送到主分支,其他人只能从中拉取。
如何在 git 中实现这一点?
重要的
我们有自己的服务器端,我们不使用gitlab,github等等。
我知道你可以在钩子的帮助下以某种方式做到这一点......
有例子吗?教程
如何让自己成为 git 中的分支管理员?
我们有一个人在做合并和推送到主分支,我们要确保只有他有机会推送到主分支,其他人只能从中拉取。
如何在 git 中实现这一点?
重要的
我们有自己的服务器端,我们不使用gitlab,github等等。
我知道你可以在钩子的帮助下以某种方式做到这一点......
有例子吗?教程
元函数接受要在模板中检查的类型。如果在 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
您能否使用简单的 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吗?
为什么要在方法签名中写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?
我有一个任务:我需要尽快找到几万亿个整数的整数平方根个数,不超过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++;
但事实证明,这种方法比通常的平方根计算要慢很多倍。告诉我,是否有可能使用语言工具以某种方式加速一次迭代的执行,或者用更快的方法替换根下的计算?我会很高兴任何提示!