有没有聪明的方法呢?我最好的方法是:
object next = list.get(0) ;
list.remove(0) ;
list.add(next) ;
Run Code Online (Sandbox Code Playgroud)
如果没有,是否有任何类型的集合,将使这更容易?我不喜欢需要一个临时对象来存储我想要移动的元素..
编辑:我用我的代码测试了下面列出的命题:
long starttime = System.nanoTime() ;
for (int i = 0; i < ntours; i++){
profit += retrieveGroupsWillPlay(groups, ngroups, limit) ;
}
long endtime = System.nanoTime() ;
System.out.println("Timing: " + (endtime - starttime)) ;
System.out.println("Profit: " + profit) ;
Run Code Online (Sandbox Code Playgroud)
结果如下:(利润:15,确保结果适合我的代码)代码:
private static int retrieveGroupsWillPlay(ArrayList<Integer> queue,int ngroups, int limit) {
int peopleWillPlay = 0 ;
for (int i = 0; i < ngroups; i++){
int nextGroup = queue.get(0) ;
if(limit …Run Code Online (Sandbox Code Playgroud) 我在这里有一个问题,"applicationContext.xml"中定义的bean如何可用于在"spring-servlet.xml"中定义的控制器,所以我可以跳过这种错误.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/home' defined in ServletContext resource [/WEB-INF/mmapp-servlet.xml]: Cannot resolve reference to bean 'equipementService' while setting bean property 'equipementService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'equipementService' is defined
Run Code Online (Sandbox Code Playgroud)
applicationContext.xml中
<?xml version="1.0" ?>
<!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean name="equipementService"
class="mmapp.service.SimpleEquipementService" />
<bean name="equipement1"
class="mmapp.domain.Equipement" />
</beans>
Run Code Online (Sandbox Code Playgroud)
mmapp-servlet.xml中
<?xml version="1.0" ?>
<!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean name="/home" class="mmapp.web.HelloController">
<property name="equipementService" ref="equipementService" />
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud) 当我将此行添加到我的ivy.xml文件时:
<ivy-module version="2.0">
<info organisation="Marouane" module="example"/>
<dependencies>
<dependency org="com.sun.faces" name="jsf-impl" rev="2.1.19" />
<dependency org="com.sun.faces" name="jsf-api" rev="2.1.19" />
<dependency org="org.springframework" name="spring-context" rev="3.2.1.RELEASE" />
<!-- this line -->
<dependency org="org.springframework" name="spring-web" rev="3.2.1.RELEASE" />
</dependencies>
</ivy-module>
Run Code Online (Sandbox Code Playgroud)
我有一个关于未解决的依赖项的警告,没有下载任何内容.
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: com.caucho#hessian;3.2.1: not found
::::::::::::::::::::::::::::::::::::::::::::::
Run Code Online (Sandbox Code Playgroud)
编辑:这是问题摘要:
module not found: com.caucho#hessian;3.2.1
==== local: tried
$HOME/.ivy2/local/com.caucho/hessian/3.2.1/ivys/ivy.xml
-- artifact com.caucho#hessian;3.2.1!hessian.jar:
$HOME/.ivy2/local/com.caucho/hessian/3.2.1/jars/hessian.jar
==== shared: tried
$HOME/.ivy2/shared/com.caucho/hessian/3.2.1/ivys/ivy.xml
-- artifact com.caucho#hessian;3.2.1!hessian.jar:
$HOME/.ivy2/shared/com.caucho/hessian/3.2.1/jars/hessian.jar
==== public: tried
http://repo1.maven.org/maven2/com/caucho/hessian/3.2.1/hessian-3.2.1.pom
-- artifact com.caucho#hessian;3.2.1!hessian.jar:
http://repo1.maven.org/maven2/com/caucho/hessian/3.2.1/hessian-3.2.1.jar
Run Code Online (Sandbox Code Playgroud)
我参观了Maven仓库网站,Spring的web 3.2.1的页面,粗麻布3.2.1被列为依赖关系,但在粗麻布的页面存在的3.2.1版本没有麻袋包,这是什么问题?我该怎么办?
我试图为降价标头创建一个运算符挂起映射,这是学习 vim 脚本的一个练习,这里是我的 vimrc 中的行:
autocmd Filetype markdown :onoremap ih :<c-u>execute "normal! ?\\(^==\\+$\\|^--\\+$\\)\r:nohlsearch\rkvg_"<cr>
Run Code Online (Sandbox Code Playgroud)
我有这个错误
E486: Pattern not found: \(^==\+$|^--\+$\)
Run Code Online (Sandbox Code Playgroud)
我尝试了一些修改,但我得到了相同的结果,就像管道永远不会逃脱一样!