我在LibGdx Stage对象中排序Actors时遇到问题.舞台渲染后,图像按照添加顺序渲染.Stage使用Array来保存Actors.我已经尝试设置每个Actor的ZIndex,但它仍然没有排序.然后我尝试创建一个像这样的比较器对象:
public class ActorComparator implements Comparator < Actor > {
@Override
public int compare(Actor arg0, Actor arg1) {
if (arg0.getZIndex() < arg1.getZIndex()) {
return -1;
} else if (arg0.getZIndex() == arg1.getZIndex()) {
return 0;
} else {
return 1;
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后当我想做我做的实际比较时:
Collections.sort(Stage.getActors(), new ActorComparator());
Run Code Online (Sandbox Code Playgroud)
它给我以下错误,不会编译:
The method sort(List<T>, Comparator<? super T>) in the type Collections
is not applicable for the arguments (Array<Actor>, ActorComparator)
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么.谁可以给我解释一下这个?
我不得不从许多年前业务中的某个人那里找到老化的短信系统.
它是使用ASP classic构建的,并将一个字符串发送到一个API,然后将其发送出去,所有这些既不在这里也不在那里.我遇到的问题是没有JS经验,我是SQL开发人员,几年前做过一些ASP Classic(VBScript).
这段JScript从几个表单框中获取信息,然后将它们放在一个字符串中,然后将其传递给处理页面上的变量以进行文本输出.字段'QValue,Indemnity和Excess'都是数字.封面是文本,它正在用'NaN'替换封面文本,现在我明白这是'非数字',这正是它的原因,而不是数字,但我想要文本字符串.
以下是有问题的代码片段:
<script type="text/javascript">
function changeMessageText()
{
var messagetxt = document.getElementById('message').value
var QValue = document.getElementById('QValue').value
var Cover = document.getElementById('Cover').value
var Excess = document.getElementById('Excess').value
var Indem = document.getElementById('Indemnity').value
var messagetxt=messagetxt.replace("[QValue]", + QValue)
var messagetxt=messagetxt.replace("[Cover]", + Cover2)
var messagetxt=messagetxt.replace("[Excess]", + Excess)
var messagetxt=messagetxt.replace("[Indem]", + Indem)
document.getElementById('messageText').innerHTML = messagetxt;
}
</script>
Run Code Online (Sandbox Code Playgroud)
干杯.
您好我正在尝试从最高值先排序浮点数列表,然后再排列到ArrayList中的最低值.
CustomObject包含一个对象,该对象的值为float.
到目前为止,我正在这样做(失败,没有做任何事情).
Collections.sort(mNaturalResistanceBoxes, new Comparator < PercentageBox > () {
public int compare(PercentageBox o1, PercentageBox o2) {
return o1.mCountry.mNaturalResistance
< o2.mCountry.mNaturalResistance ? -1 :
o1.mCountry.mNaturalResistance > o2.mCountry.mNaturalResistance ? 1 : 0;
}
});
Run Code Online (Sandbox Code Playgroud)
任何人都可以让我知道我在哪里错了吗?