equivalence

What are uses of the C++ construct "placement new"?

I just learned about the C++ construct called "placement new". It allows you to exactly control where a pointer points to in memory. It looks like this: #include <new> // Must #include this to use "placement new" #include "Fred.h" // Declaration of class Fred void someCode() { char memory[sizeof(Fred)]; void* pla...

Elegant ways to support equivalence ("equality") in Python classes

When writing custom classes it is often important to allow equivalence by means of the == and != operators. In Python, this is made possible by implementing the __eq__ and __ne__ special methods, respectively. The easiest way I've found to do this is the following method: class Foo: def __init__(self, item): self.item = item...

How to reduce a logical statement?

I'm pretty sure I can remember doing something like this in one of my college level courses and that there was some kind of formula to it, but my mind is failing me beyond that. Given the statement: ( a OR b OR d ) AND ( a OR c ) I'm pretty sure that this can be reduced to: ( a OR b OR d OR c ) But I cannot remember how I would go abo...

Determining object equivalence for value types, reference types and ILists in .net

I have a class with a Property called 'Value' which is of type Object. Value can be of any type, a structure, a class, an array, IList etc. My problem is with the setter and determining whether the value has changed or not. This is simple enough for value types, but reference types and lists present a problem. For a class, would you as...

Java: Equalator? (removing duplicates from a collection of objects)

I have a bunch of objects of a class Puzzle. I have overridden equals() and hashCode(). When it comes time to present the solutions to the user, I'd like to filter out all the Puzzles that are "similar" (by the standard I have defined), so the user only sees one of each. Similarity is transitive. Example: Result of computations: A ...

Boxed Primitives and Equivalence

So I was asked this question today. Integer a = 3; Integer b = 2; Integer c = 5; Integer d = a + b; System.out.println(c == d); What will this program print out? It returns true. I answered it will always print out false because of how I understood auto (and auto un) boxing. I was under the impression that assigning Integer a = 3 wil...

What is C# 'internal' in VB.net?

What is C# 'internal' in VB.net? Simple question, hard to find! ...

Equivalence Classes LISP

I need to write a program for equivalence classes and get this outputs... (equiv '((a b) (a c) (d e) (e f) (c g) (g h))) => ((a b c g h) (d e f)) (equiv '((a b) (c d) (e f) (f g) (a e))) => ((a b e f g) (c d)) Basically, A set is a list in which the order doesn't matter, but elements don't appear more than once. The function shoul...

Is there equivalences between Microsoft and Oracle/Sun technologies?

Hello is it possible to say what are the Microsoft equivalents technologies compared to Sun? For example: Microsoft | Oracle/Sun --------------------------------------------------------------- Visual Studio | JDeveloper,NetBeans //thanks justin,danswain IIS ...

Scheme symbolic equivalence

Hi all. The platform i'm working with is DrScheme. I've seen that a pair (a b) [constructed by (cons a b)] is implemented within the language like a procedure that looks like this: (define (cons a b) (lambda(pick) (cond ((= pick 1) a) ((= pick 2) b)))) and the selectors: (define (car x) (x 1)) (define (cdr x) (x 2))...

Database Theory: Transaction serializability

Hy, I'm learning for my exams and came over the following question: Take the History (or Schedule) H = w1[x] w2[x] w2[y] c2 w1[y] w3[x] w3[y] c3 w1[z] c1 where w1[x] means: Transaction 1 writes to Data-Object X (r1[x] means read) and c1 means: Transaction 1 commits. Why is this transaction view serializable? For view Serializabilit...

Equivalence relational algebra and turing langauge

Hi, I'm starting a project where I want to try to recognize relational algebra's in java-like programming language. For example, given two relations: AmericanActor(Name) EuropianActor(Name) The following expression in RA: AmericanActor U EuropianActor should be equivalent to the following program: void RAMethod(Set<Name> AmericanA...

Trying to find an algorithm which takes 2 regular expressions and tells whether they are equivalent

I'm trying to find out what the algorithm would be by being given two languages L1 and L2 to determine if they are equivalent (L1 = L2). It's surprisingly difficult to come up with one as I've found, although I am pretty sure it needs to be converted to a DFA first and then reduce each of them to a minimal DFA.. Also, I know that if L1...