@@ -172,20 +172,6 @@ setMethod("bindROWS", "XVector", .concatenate_XVector_objects)
172172# ## order() and sameAsPreviousROW are required to make XVector compatible with
173173# ## the equality functions defined in S4Vectors
174174
175- .XVector.equal <- function (x , y )
176- {
177- if (class(x ) != class(y ) || x @ length != y @ length )
178- return (FALSE )
179- ans <- ! SharedVector.compare(x @ shared , x @ offset + 1L ,
180- y @ shared , y @ offset + 1L ,
181- x @ length )
182- as.logical(ans )
183- }
184-
185- setMethod(" ==" , signature(e1 = " XVector" , e2 = " XVector" ),
186- function (e1 , e2 ) .XVector.equal(e1 , e2 )
187- )
188-
189175.XVector.order <- function (x , decreasing = FALSE ){
190176 SharedVector.order(x @ shared , decreasing )
191177}
@@ -213,3 +199,31 @@ setMethod("order", "XVector",
213199 }
214200}
215201setMethod ("sameAsPreviousROW ", "XVector", .XVector.sameAsPreviousROW)
202+
203+ # # These methods are defined so that the XVector argument comes first
204+ # # this matters because of how S4Vectors::pcompare is defined; it attempts
205+ # # to coerce the second argument to a list and then concatenate, which can
206+ # # cause weird behavior if the first element is an atomic vector and the
207+ # # second is an XVector object.
208+ setMethod(" ==" , signature(e1 = " ANY" , e2 = " XVector" ),
209+ function (e1 , e2 ) { pcompare(e2 , e1 ) == 0 }
210+ )
211+
212+ setMethod(" <=" , signature(e1 = " ANY" , e2 = " XVector" ),
213+ function (e1 , e2 ) { pcompare(e2 , e1 ) > = 0L }
214+ )
215+
216+ .XVector.equal <- function (x , y )
217+ {
218+ if (class(x ) != class(y ) || x @ length != y @ length )
219+ return (FALSE )
220+ ans <- ! SharedVector.compare(x @ shared , x @ offset + 1L ,
221+ y @ shared , y @ offset + 1L ,
222+ x @ length )
223+ as.logical(ans )
224+ }
225+
226+ setMethod(" ==" , signature(e1 = " XVector" , e2 = " XVector" ),
227+ function (e1 , e2 ) .XVector.equal(e1 , e2 )
228+ )
229+
0 commit comments