Questions tagged [comparison]

Questions about data comparison and efficient ways to accomplish it. Please avoid using this tag for generic (meta) comparison of two issues or concepts.

Questions about data comparison and efficient ways to accomplish it, e.g.: "Which is the fastest algorithm to compare two recordsets and decide which one has more palindromes?", or "What is the fastest way to compare two strings and say if they have more than Y characters in common?"

There are generally six basic "comparison operators": less than, <; less than or equal to, <=; equal to, ==; not equal to, !=; greater than or equal to, >=; and greater than, >.

8118 questions
111
votes
20 answers

Comparing object properties in c#

This is what I've come up with as a method on a class inherited by many of my other classes. The idea is that it allows the simple comparison between properties of Objects of the same Type. Now, this does work - but in the interest of improving the…
nailitdown
  • 7,868
  • 11
  • 36
  • 37
109
votes
5 answers

How can I compare a string to multiple correct values in Bash?

I have the following piece of Bash script: function get_cms { echo "input cms name" read cms cms=${cms,,} if [ "$cms" != "wordpress" && "$cms" != "meganto" && "$cms" != "typo3" ]; then get_cms fi } But no matter what I…
eagle00789
  • 1,211
  • 2
  • 8
  • 6
108
votes
9 answers

Check if two arrays have the same contents (in any order)

I'm using Ruby 1.8.6 with Rails 1.2.3, and need to determine whether two arrays have the same elements, regardless of whether or not they're in the same order. One of the arrays is guaranteed not to contain duplicates (the other might, in which case…
Taymon
  • 24,950
  • 9
  • 62
  • 84
105
votes
14 answers

Is there a Java utility to do a deep comparison of two objects?

How to "deep"-compare two objects that do not implement the equals method based on their field values in a test? Original Question (closed because lack of precision and thus not fulfilling SO standards), kept for documentation purposes: I'm trying…
Uri
  • 88,451
  • 51
  • 221
  • 321
104
votes
18 answers

Java Embedded Databases Comparison

I intend to develop a small (Java) application for managing my finances. I believe I need to use an embedded database, but I have no experience regarding this issue. I tried to look at some of the available products, but I can't decide which one…
Hosam Aly
  • 41,555
  • 36
  • 141
  • 182
104
votes
8 answers

Haskell, Lisp, and verbosity

For those of you experienced in both Haskell and some flavor of Lisp, I'm curious how "pleasant" (to use a horrid term) it is to write code in Haskell vs. Lisp. Some background: I'm learning Haskell now, having earlier worked with Scheme and CL (and…
J Cooper
  • 16,891
  • 12
  • 65
  • 110
104
votes
13 answers

Determining if a number is either a multiple of ten or within a particular set of ranges

I have a few loops that I need in my program. I can write out the pseudo code, but I'm not entirely sure how to write them logically. I need - if (num is a multiple of 10) { do this } if (num is within 11-20, 31-40, 51-60, 71-80, 91-100) { do this…
user3419168
  • 1,135
  • 2
  • 8
  • 16
103
votes
4 answers

Clojure vs other Lisps

The intent of my question is not to start a flame war, but rather to determine in what circumstances each language is "the best tool for the job." I have read several books on Clojure (Programming Clojure, Practical Clojure, The Joy of Clojure, and…
Ralph
  • 31,584
  • 38
  • 145
  • 282
103
votes
6 answers

Signed/unsigned comparisons

I'm trying to understand why the following code doesn't issue a warning at the indicated place. //from limits.h #define UINT_MAX 0xffffffff /* maximum unsigned int value */ #define INT_MAX 2147483647 /* maximum (signed) int value */ /*…
Peter
  • 1,031
  • 2
  • 8
  • 4
103
votes
2 answers

How does a Python set([]) check if two objects are equal? What methods does an object need to define to customise this?

I need to create a 'container' object or class in Python, which keeps a record of other objects which I also define. One requirement of this container is that if two objects are deemed to be identical, one (either one) is removed. My first thought…
Ada
  • 1,746
  • 4
  • 15
  • 15
101
votes
6 answers

Why would you use Oracle database?

I'm curious for technical reasons why you choose Oracle database versus the latest flavors of: 1) Microsoft SQL Server 2) MySQL 3) PostgreSQL What features or functionality justify the extra cost. I'm interested in technical arguments, not a…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
99
votes
4 answers

Comparing two CGRects

I needed to check wether the frame of my view is equal to a given CGRect. I tried doing that like this: CGRect rect = CGRectMake(20, 20, 20, 20); if (self.view.frame == rect) { // do some stuff } However, I got an error saying Invalid operands…
Tim Vermeulen
  • 12,352
  • 9
  • 44
  • 63
96
votes
8 answers

What's the prettiest way to compare one value against multiple values?

Whats the prettiest way to compare one value against multiples options? I know there are loads of ways of doing this, but I'm looking for the neatest. i ask because i'd hoped this was workable (it isn't, quite obviously when you look at it): if…
thelastshadow
  • 3,406
  • 3
  • 33
  • 36
96
votes
4 answers

Protocol Buffers versus JSON or BSON

Does anyone have any information on the performance characteristics of Protocol Buffers versus BSON (binary JSON) or versus JSON in general? Wire size Serialization speed Deserialization speed These seem like good binary protocols for use over…
Jeff Meatball Yang
  • 37,839
  • 27
  • 91
  • 125
96
votes
1 answer

double equals vs is in python

I run the following in the Python interpreter: >>> foo = 10 >>> dir(foo) == dir(10) True >>> dir(foo) is dir(10) False >>> Why is this?
ben
  • 1,583
  • 2
  • 11
  • 12