找回密码
 注册
查看: 1393|回复: 0

R语言 rJava包 jequals()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-22 21:03:30 | 显示全部楼层 |阅读模式
jequals(rJava)
jequals()所属R语言包:rJava

                                         Comparing Java References
                                         比较的Java参考

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

.jequals function can be used to determine whether two objects are equal. In addition, it allows mixed comparison of non-Java object for convenience, unless strict comparison is desired.
.jequals函数可以用来确定两个对象是否相等。此外,它允许非Java对象的混合比较方便,除非需要进行严格比较。

The binary operators == and != are mapped to (non-strict) call to .jequals for convenience.
二元运算符==和!=映射到呼叫(非严格)为方便起见,.jequals。

.jcompare compares two objects in the sense of the  java.lang.Comparable interface.
.jcompare感java.lang.Comparable接口比较两个对象。

The binary operators <, >, <=, >= are mapped  to calls to .jcompare for convenience
二元运算符<,>,<=,>=.jcompare为了方便调用映射到


用法----------Usage----------


.jequals(a, b, strict = FALSE)
.jcompare( a, b )



参数----------Arguments----------

参数:a
first object
第一个对象


参数:b
second object
第二个对象


参数:strict
when set to TRUE then non-references save for NULL are always treated as different, see details.
当设置为TRUE然后保存NULL总是因为不同的治疗,见详情非引用。


Details

详情----------Details----------

.jequals compares two Java objects by calling equals method of one of the objects and passing the other object as its argument. This allows Java objects to define the "equality" in object-dependent way.
.jequals比较两个Java对象通过调用equals方法的对象之一,并通过其他对象作为它的参数。这使得Java对象定义依赖对象的方式中的“平等”。

In addition, .jequals allows the comparison of Java object to other scalar R objects. This is done by creating a temporary Java object that corresponds to the R object and using it for a call to the equals method. If such conversion is not possible a warning is produced and the result it FALSE. The automatic conversion will be avoided if strict parameter is set to TRUE.
此外,.jequals允许Java对象相比,其他标R对象。这是通过创建一个临时的Java对象对应的R对象和使用为equals方法的调用它。如果这种转换是不可能的警告产生的结果FALSE。设置strict如果TRUE参数,自动转换,将可避免。

NULL values in a or b are replaced by Java null-references and thus .jequals(NULL,NULL) is TRUE.
NULL值a或b的Javanull引用取代,从而.jequals(NULL,NULL)是TRUE。

If neither a and b are Java objects (with the exception of both being NULL) then the result is identical to that of all.equal(a,b).
如果没有a和bJava对象(异常都NULL),那么结果是相同的all.equal(a,b)。

Neither comparison operators nor .jequals supports vectors and returns FALSE in that case. A warning is also issued unless strict comparison was requested.
既不比较运算符,也不.jequals支持向量并返回FALSE在这种情况下。也发出警告,除非被要求进行严格比较。


值----------Value----------

.jequals returns TRUE if both object  are considered equal, FALSE otherwise.
.jequals返回TRUE如果两个对象被认为是相等的,FALSE否则。

.jcompare returns the result of the compareTo java method of the object a applied to b
.jcompare返回compareTojava对象的方法应用于B


方法----------Methods----------




!= signature(e1 = "ANY", e2 = "jobjRef"): ...
=signature(e1 = "ANY", e2 = "jobjRef")...




!= signature(e1 = "jobjRef", e2 = "jobjRef"): ...
=signature(e1 = "jobjRef", e2 = "jobjRef")...




!= signature(e1 = "jobjRef", e2 = "ANY"): ...
=signature(e1 = "jobjRef", e2 = "ANY")...




== signature(e1 = "ANY", e2 = "jobjRef"): ...
==signature(e1 = "ANY", e2 = "jobjRef"):...




== signature(e1 = "jobjRef", e2 = "jobjRef"): ...
==signature(e1 = "jobjRef", e2 = "jobjRef"):...




== signature(e1 = "jobjRef", e2 = "ANY"): ...
==signature(e1 = "jobjRef", e2 = "ANY"):...




< signature(e1 = "ANY", e2 = "jobjRef"): ...
<signature(e1 = "ANY", e2 = "jobjRef"):...




< signature(e1 = "jobjRef", e2 = "jobjRef"): ...
<signature(e1 = "jobjRef", e2 = "jobjRef"):...




< signature(e1 = "jobjRef", e2 = "ANY"): ...
<signature(e1 = "jobjRef", e2 = "ANY"):...




> signature(e1 = "ANY", e2 = "jobjRef"): ...
>signature(e1 = "ANY", e2 = "jobjRef")...




> signature(e1 = "jobjRef", e2 = "jobjRef"): ...
>signature(e1 = "jobjRef", e2 = "jobjRef")...




> signature(e1 = "jobjRef", e2 = "ANY"): ...
>signature(e1 = "jobjRef", e2 = "ANY")...




>= signature(e1 = "ANY", e2 = "jobjRef"): ...
> =signature(e1 = "ANY", e2 = "jobjRef"):...




>= signature(e1 = "jobjRef", e2 = "jobjRef"): ...
> =signature(e1 = "jobjRef", e2 = "jobjRef"):...




>= signature(e1 = "jobjRef", e2 = "ANY"): ...
> =signature(e1 = "jobjRef", e2 = "ANY"):...




<= signature(e1 = "ANY", e2 = "jobjRef"): ...
<=signature(e1 = "ANY", e2 = "jobjRef"):...




<= signature(e1 = "jobjRef", e2 = "jobjRef"): ...
<=signature(e1 = "jobjRef", e2 = "jobjRef"):...




<= signature(e1 = "jobjRef", e2 = "ANY"): ...
<=signature(e1 = "jobjRef", e2 = "ANY"):...


注意----------Note----------

Don't use x == NULL to check for null-references, because x could be NULL and thus the result would be an empty vector. Use is.jnull instead. (In theory is.jnull and x == .jnull() are the the same, but is.jnull is more efficient.)
千万不要使用x == NULL检查null引用,因为x能NULL,因而其结果将是一个空向量。使用is.jnull代替。 (理论is.jnull和x == .jnull()是相同的,但,is.jnull是更有效。)


参见----------See Also----------

is.jnull
is.jnull


举例----------Examples----------



s <- .jnew("java/lang/String", "foo")
.jequals(s, "foo") # TRUE[真]
.jequals(s, "foo", strict=TRUE) # FALSE - "foo" is not a Java object[假 - “foo”是不是一个Java对象]
t <- s
.jequals(s, t, strict=TRUE) # TRUE[真]

s=="foo" # TRUE[真]



Double <- J("java.lang.Double")
d1 <- new( Double, 0.0 )
d2 <- new( Double, 1.0 )
d3 <- new( Double, 0.0 )

d1 < d2
d1 <= d3
d1 >= d3
d1 > d2

# cannot compare a Double and a String[无法比拟的一张双人床和一个String]
try( d1 < "foo" )

# but can compare a Double and an Integer[但可以比较一张双人床和一个整数]
d1 < 10L





转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-6-8 18:39 , Processed in 0.021522 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表