我刚开始使用Maven,我被告知要mvn install在特定的目录中进行操作.
到底mvn install做了什么?
我认为它pom.xml在当前文件夹中查找并开始按照该文件中指定的说明进行操作.那是对的吗?
我刚开始使用Maven,我读到插件是可以使用的附加组件.
典型的pom.xml文件结构是
<project>
<groupId>org.koshik.javabrains</groupId>
<artifactId>JarName</artifactId> (A fldernamed JarName was created)
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JarName</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
问题:我应该在哪里插入plugin标签?如下:
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.4</version>
<executions>
<execution>
<goals>
<goal>bind</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在依赖之前还是在dependency标记之后?有关系吗?
我只是下载Git bash,现在我想从Bitbucket下载一个存储库.我有用户名和密码.
当我尝试:
$ git clone https://xxxxx@bitbucket.org/xxxx/xxxxx.git
Run Code Online (Sandbox Code Playgroud)
我明白了:
Cloning into 'xxxx'...
fatal:https://xxxxx@bitbucket.org/xxxx/xxxxx/info/refs not found did you git
update server-info on the server ?
Run Code Online (Sandbox Code Playgroud) 我已经读过,在a的末尾添加项目的时间复杂度std::vector是分摊的常量,并且在a的顶部和底部插入项目std::deque是常量.因为这两个容器都具有随机访问迭代器,因此访问任何索引处的元素是不变的.如果我有任何这些事实错误,请告诉我.我的问题是如果访问a中的元素std::vector或者std::deque是不变的那么为什么通过擦除O(n)去除元素的时间复杂度.这里的答案之一说明通过擦除元素是O(n).我知道擦除会删除起始迭代器和结束迭代器之间的元素,所以答案基本上意味着它O(n) 取决于两个迭代器之间的元素的数量,并且从任何索引中的vector/deque中删除单个元素将为零?
我目前有一个方法如下
void SomeMethod(int a)
{
//Delay for one sec.
timer->start(1000);
//After one sec
SomeOtherFunction(a);
}
Run Code Online (Sandbox Code Playgroud)
该方法实际上是附加到信号的插槽.我想用Qtimer添加一秒的延迟.但是我不知道如何实现这一点.由于定时器在完成时触发信号,并且信号需要连接到另一个不接受任何参数的方法.关于如何完成这项任务的任何建议.
更新: 信号将在一秒钟内被多次调用,延迟将持续一秒钟.我的问题是将参数传递给附加到计时器的timeout()信号的插槽.我的最后一种方法是将值存储在类的memeber变量中,然后使用互斥锁来保护它在使用变量时不被更改.但是我在这里寻找更简单的方法.
对于我总是用于循环的post增量运算符,我并不是很清楚.我对post增量运算符的最新和新获得的理解如下:
int a = 5
int b = a++ //a will increment and return back its old value 5
so b = 5
Run Code Online (Sandbox Code Playgroud)
有了这些新知识,我决定理解/应用于我常用的后增量运算符的地方for.现在好像我迷失了,因为理论上我输错了输出
请考虑以下代码
for(int i=0 ; i< 3 ; i++)
{
std::cout << i;
}
Run Code Online (Sandbox Code Playgroud)
第一个循环
i starts with 0 which is less than 3 so ( increment by 1 however since its i++ it returns old value 0)
so cout should display 1 // But it displays 0
Run Code Online (Sandbox Code Playgroud)
第二圈
i is now 1 which is …Run Code Online (Sandbox Code Playgroud) 我已经读过weak_pointers可以用来打破循环引用.
请考虑以下循环引用示例
struct A
{
boost::shared_ptr<A> shrd_ptr;
};
boost::shared_ptr<A> ptr_A(boost::make_shared<A>());
boost::shared_ptr<A> ptr_b(boost::make_shared<A>());
ptr_A->shrd_ptr = ptr_b;
ptr_b->shrd_ptr = ptr_A;
Run Code Online (Sandbox Code Playgroud)
现在上面是一个循环引用的例子,我想知道如何通过使用来打破上面的循环引用weak_ptr?
更新:根据收到的建议,我想出了以下内容:
struct A
{
boost::weak_ptr<A> wk_ptr;
};
boost::shared_ptr<A> ptr_A (boost::make_shared<A>());
boost::shared_ptr<A> ptr_B (boost::make_shared<A>());
ptr_A->wk_ptr = ptr_B;
ptr_B->wk_ptr = ptr_A;
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
我试图QCustomPlot在我的线条样式中显示不同点的绘图值lsLine.我知道我可以设置一个鼠标悬停在信号上QCustomPlot但不会真正有用,因为我只需要在鼠标悬停在绘制的线上时得到通知.我的问题是有没有办法找出鼠标是否在我的散点上.是否有可以连接的信号,当鼠标在散点上时会告诉我?
我读到这里从一个std ::双端队列具有以下特点公认的答案
1- Random access - constant O(1)
2- Insertion or removal of elements at the end or beginning - amortized constant O(1)
3- Insertion or removal of elements - linear O(n)
Run Code Online (Sandbox Code Playgroud)
我的问题是关于第2点.双端队列如何在结束或开始时进行摊销?
我知道a std::vector在最后插入时具有摊销的常数时间复杂度.这是因为矢量是连续的并且是动态阵列.因此,当最后一个内存耗尽push_back时,它将分配一个全新的内存块,将现有项目从旧位置复制到新位置,然后从旧位置删除项目.我理解的这个操作是摊销不变的.这如何适用于双端队列?如何在双端队列的顶部和底部插入是否可以摊销.我的印象是它应该是常数O(1).我知道一个双端队列由内存块组成.