comparison

Is it possible to compare two Objective-C blocks by content?

float pi = 3.14; float (^piSquare)(void) = ^(void){ return pi * pi; }; float (^piSquare2)(void) = ^(void){ return pi * pi; }; [piSquare isEqualTo: piSquare2]; // -> want it to behave like -isEqualToString... ...

In bash, how can I check if a string begins with some value?

Hi, I would like to check if a string begins with "node" e.g. "node001". Something like if [ $HOST == user* ] then echo yes fi How can I do it correctly? Thanks! UPDATE: Thank you so much! I further need to combine expressions to check if HOST is either "user1" or begins with "node" if [ [[ $HOST == user1 ]] -o [[ $HO...

C# byte[] comparison without bound checks

I am looking for performance efficient ways to compare two byte[] for equality. Sizes are above 1 MB, so the overhead for each array element should be minimized. I aim to beat the speeds of SequenceEqual or a hand-coded for-loop over every item, by avoiding the repetitive bound checks for both arrays. In the same way that Array.Copy co...

What is the difference between google's ImmutableList and Collections.unmodifiableList ()?

From ImmutableList javadocs: Unlike Collections.unmodifiableList(java.util.List), which is a view of a separate collection that can still change, an instance of ImmutableList contains its own private data and will never change. ImmutableList is convenient for public static final lists ("constant lists") and also lets ...

Can two booleans be compared in C++?

Is the following piece of code supposed to work? bool b1 = true; bool b2 = 1 < 2; if (b1 == b2) { // do something } I suspect that not all 'trues' are equal. ...

Python underlying analysis books/articles?

Does anyone know good books that discuss the underlying architectures, in-depth analysis of CPython implementation. Something like how list / tuple / dict implemented (and performance comparison...) OOP discussion in Python context Sorry if it sounds like a silly question :( ...

Comparing Hashtables in vb.net

I have a type of object called Bin, which has a hashtable field called Attributes. Like so: Public Class Bin Private _attributes As Hashtable Public Readonly Property Attributes() As Hashtable Get Return _attributes End Get End Property End Class If I have two bins, I'd like to compare if they...

comparing jQuery objects

I'm using a selector to get a group of objects (0 or more): var $openMenus = $Triggers.filter(".trigger-hover"); Then I have an event attached to an item that may or may not be in the object above. Within that event where I want to compare the item that triggers the event to c $([selector]) .focus(function(){ var $thisMen...

How do I compare all elements of two arrays in MATLAB?

I have two big arrays with about 1000 rows and 1000 columns. I need to compare each element of these arrays and store 1 in another array if the corresponding elements are equal. I can do this with for loops but that takes a long time. How can I do this faster? ...

Value before variable

I'm looking at some SQL code which has a WHERE clause like this: WHERE 'USD' = CCY I asked the writer why he's putting the value on the left hand side, and he said it's best practice to do so, stemming from C++ where people could mistakenly assign the value instead of comparing equality by forgetting the second equals sign. I've neve...

MATLAB: comparing all elements of two arrays

I have two matrices in MATLAB lets say arr1 and arr2 of size 1000*1000 each. I want to compare their elements and save the comparison in a result matrix resarr which is also 1000*1000 such that for each element: if the element in arr1 is bigger than the one in arr2, place the value 1 in the result if the element in arr2 is bigger, stor...

Is it impossible to use stl map with struct ?

struct Node { int a; int b; }; Node node; node.a = 2; node.b = 3; map<int, int> aa; aa[1]=1; //O.K. map<Node, int> bb; bb[node]=1; //Compile Error When I tried to map a struct into int, it gave me a compile error. Why? Thank you! ...

What’s the difference between ScalaTest and Scala Specs unit test frameworks?

Both are BDD (Behavior Driven Development) capable unit test frameworks for Scala written in Scala. And Specs is built upon may also involve the ScalaTest framework. But what does Specs offer ScalaTest doesn't? What are the differences? ...

Detect anchor is leading to an active window.location

Having such an html: <a class="someclass" href="some/url/absolute/or/relative">Blah</a> ... along with such javascript: $("a.someclass").onclick(function() { var link = $(this).attr("href"); if (link == window.location) // <<<<<<<<<<<< doSomethingSpecial(); else doOtherThing(); return false; }); this...

What is the difference between platform and tool?

The question is telling everything Reason why I ask: Maven is more of a platform than a tool, while you could consider Maven an alternative to Ant, you are comparing apples to oranges. "Maven" includes more than just a build tool. What the heck does this mean? ...

Python comparison evaluation

As per the python documentation,x<y<z comparison is translated to x<y and y<z and expression y is evaluated only once at most. Now my question is , does an expression y ( look at the code below) is evaluated only once here? if(x<y and y<z): ...

Assign a value equal only to itself

I wish to assign to a variable (a "constant"), a value that will allow that variable to only ever return True in is and == comparisons against itself. I want to avoid assigning an arbitary value such as an int or some other type on the off chance that the value I choose clashes with some other. I'm considering generating an instance of...

C# - fastest way to compare two strings using wildcards

Is there a fastest way to compare two strings (using the space for a wildcard) than this function? public static bool CustomCompare(this string word, string mask) { for (int index = 0; index < mask.Length; index++) { if (mask[index] != ' ') && (mask[index]!= word[index])) { return false; } ...

Is it reliable to compare two instances of a class by comparing their serialized byte arrays?

Given two instances of a class, is it a good and reliable practice to compare them by serializaing them first and then comparing byte arrays (or possibly hashes of arrays). These objects might have complex hierarchical properties but serialization should go as deep as required. By comparison I mean the process of making sure that all p...

How to improve Visual C++ compilation times?

I am compiling 2 C++ projects in a buildbot, on each commit. Both are around 1000 files, one is 100 kloc, the other 170 kloc. Compilation times are very different from gcc (4.4) to Visual C++ (2008). Visual C++ compilations for one project take in the 20 minutes. They cannot take advantage of the multiple cores because a project depend ...