Questions tagged [deepequals]

If this tag is used for Java 7's `deepEquals` function which provides comparison for objects or arrays of objects across properties, please also use the [java-7] or [java] tags. Otherwise, this tag may be used for any sort of operator in any language that compares objects and takes their properties into account.

If this tag is used for Java 7's deepEquals function which provides comparison for objects or arrays of objects across properties, please also use the [java-7] or [java] tags. Otherwise, this tag may be used for any sort of operator in any language that compares objects and takes their properties into account.

For reference: Java 7's Object deepEquals() and Array deepEquals() functions.

30 questions
17
votes
5 answers

On Java 7's equals() and deepEquals()

Method description says: Returns true if the arguments are deeply equal to each other and false otherwise... Equality is determined by using the equals method of the first argument. Which (to me) suggests that Objects are deeply equal if every…
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
10
votes
1 answer

How does one do a deepEqual assertion with should.js?

I've tried to make a deepEqual assertion with should.js (the latest version) and have not had any success. I can get things to work with equal but not with deepEqual. In fact I am seeing that there is no deepEqual method. Here's what I've tried: >…
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
6
votes
3 answers

What is the fastest and efficient way to check Deep Equal for two java objects?

I have got two java objects with byte[] field of the size of the order of millions. What is the fastest and efficient way to check Deep Equal for these java objects? Sample Entity: @Entity public class NormalBook { @Id private String bookId; …
Dev
  • 13,492
  • 19
  • 81
  • 174
4
votes
0 answers

TypeScript Set with custom equals method

I'm currently trying to do the following. I am using a Set to store objects. Now as Typescript uses SameZeroEquality for comparing Objects the default has will not work. So I am trying to build an AdvancedSet that defines a custom has method. So far…
relief.melone
  • 3,042
  • 1
  • 28
  • 57
4
votes
1 answer

ClojureScript deep equal for JavaScript objects

I've ran into the problem how to compare two JavaScript objects for deep equality in ClojureScript, because (= var1 var2 var3...) only works on Clojure/ClojureScript collections and numbers. (= (js-obj "a" 1) (js-obj "a" 1)) ;; => false While I…
atevm
  • 801
  • 1
  • 14
  • 27
3
votes
1 answer

deepEquals - Lists are equal, Sets are not

I have a class M with hashCode() and equals() generated by Eclipse (please see below). Two lists with equal M's are equal, Two sets with equal M's are not equal. Is this a bug in deepEquals() or am I confused? import java.util.ArrayList; import…
Ray Tayek
  • 9,841
  • 8
  • 50
  • 90
2
votes
2 answers

Why does Arrays.deepEquals(Object[]arr1,Object[]arr2) works for primitive multidimensional arrays like int[][] ,float[][] etc?

From method signature it is very clear that method accepts the argument of type Object[] but still this method works perfectly fine for primitive multidimensional arrays ?(like int[][],float[][] etc) (However it shows error for primitive one…
2
votes
3 answers

How do I check if two simple 2D arrays have the same 1D arrays? (order and repetitions doesn't matter)

My main objective is to return if all elements, int[ ], of a 2D Array ,int[ ][ ], are present in another 2D Array. I already tried to use Arrays.deepEquals() but in this case, the order of the elements would matter and that's not the purpose. Int[…
2
votes
2 answers

Ignore property with list type with DeepEquals

I am using the DeepEqual library, to test if the results of a test match my expected output. I do the comparison simply as results.ShouldDeepEqual(expected); However, I don't know how to ignore a property within my list type The type I am deep…
Paul
  • 2,773
  • 7
  • 41
  • 96
2
votes
1 answer

Why does ava fail comparing list of objects and list of object literal?

I'm using the deepEqual assertion, but my test fails Test test('should return list of printers', t => { const clipboard = filter.asClipboardContent(scan); t.is(clipboard, [ {hostname: '10.0.1.1', port: '9100', description: 'HP…
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
2
votes
0 answers

2 [][] int Arrays have the exact same values, in the exact same position...How to check that efficiently?

I need help with my Multidimensional int [][] in Java. The first one is: int [][] startArr = {{0,1,2},{3,4,5},{6,7,8}}; The second is: int [][] testArr = {{0,1,2},{3,4,5},{6,7,8}}; Arrays.deepEquals(startArr, testArr) returns false...But…
user5762337
2
votes
3 answers

How to do a deepequals on a object in python

Is there a function so that I can do class Test(): def __init__(self): self.value_1 = 42 x = Test() y = Test() deepequals(x, y) == True x.value = 7 deepequals(x, y) == False y.value = 7 deepequals(x, y) == True However, by default, it…
muddyfish
  • 3,530
  • 30
  • 37
1
vote
2 answers

Time complexity of Arrays.deepEquals() in Java

I'm trying to figure out the time complexity for the java.util.Arrays deepEquals() method. I could understand from the source code that equals() method runs in O(n) time, but it's not really that clear to deduce the time complexity from the…
dynamitem
  • 1,647
  • 6
  • 25
  • 45
1
vote
2 answers

How to compare two XmlNodes of XmlDocument in C#?

This is a sample xml. If a new font is to be added in the sense, all the existing fonts to be compare with the new font before adding to the preference. How do I check the node(font) whether already exists or not in case of…
1
vote
1 answer

DeepEqual []interface{}

Looking at the following golang code: b := []byte(`["a", "b"]`) var value interface{} json.Unmarshal(b, &value) fmt.Println(value) // Print [a b] fmt.Println(reflect.TypeOf(value)) //Print []interface {} var targetValue interface{} =…
Nathan H
  • 48,033
  • 60
  • 165
  • 247
1
2