implementation

Do Python Dicts preserve iteration order if they are not modified?

If I have a dictionary in Python, and I iterate through it once, and then again later, is the iteration order guaranteed to be preserved given that I didn't insert, delete, or update any items in the dictionary? (But I might have done look-ups). ...

Simple Suggestion / Recommendation Algorithm

I am looking for a simple suggestion algorithm to implement in to my Web App. Much like Netflix, Amazon, etc... But simpler. I don't need teams of Phd's working to get a better suggestion metric. So say I have: User1 likes Object1. User2 likes Object1 and Object2. I want to suggest to User1 they might also like Object2. I can obvi...

Representation of enums

How do enums work 'behind the scenes' in programming languages? I am guessing that each language has a different way of representing these datatypes. In java you can use the == operator, for example: public class TestEnum { private enum Test { foo, bar } public static void main(String[] args) { System.out.println(...

Is writing to a socket an arbitrary limitation of the sendfile() syscall?

Prelude sendfile() is an extremely useful syscall for two reasons: First, it's less code than a read()/write() (or recv()/send() if you prefer that jive) loop. Second, it's faster (less syscalls, implementation may copy between devices without buffer, etc...) than the aforementioned methods. Less code. More efficient. Awesome. In U...

How does Google Know you are Cloaking?

I can't seem to find any information on how google determines if you are cloaking your content. How, from a technical standpoint, do you think they are determining this? Are they sending in things other than the googlebot and comparing it to the googlebot results? Do they have a team of human beings comparing? Or can they somehow tel...

Object-Oriented Execution

Consider the following source snippets: Snippet #1 StoredProcedure sp = new StoredProcedure( "PROC_NAME", getConnection() ); sp.putParameter( "ID", getId() ); sp.execute(); Snippet #2 StoredProcedure sp = new StoredProcedure( "PROC_NAME" ); sp.setConnection( getConnection() ); sp.putParameter( "ID", getId() ); sp.execu...

Does the JVM create a mutex for every object in order to implement the 'synchronized' keyword? If not, how?

As a C++ programmer becoming more familiar with Java, it's a little odd to me to see language level support for locking on arbitrary objects without any kind of declaration that the object supports such locking. Creating mutexes for every object seems like a heavy cost to be automatically opted into. Besides memory usage, mutexes are an ...

What is "e" variable in popular implementations of Brent root finding algorithm?

I am reading the standard (Numerical Recipes and GSL C versions are identical) implementation of Brent root finding algorithm, and cannot understand the meaning of variable "e". The usage suggests that "e" is supposed to be the previous distance between the brackets. But then, why is it set to "xm" (half the distance) when we use bisect...

Understanding Generics

@Entity @Table(name = "your_entity") public class YourEntityClass implements IEntity<Long> { @Id @SequenceGenerator(name = "gen_test_entity2_id", sequenceName = "test_entity2_id_seq", allocationSize = 10) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen_test_entity2_id") pr...

How is the bsearch() function in the standard C library implemented?

Does anyone know how the standard binary search function is implemented? This is the prototype. void * bsearch (const void*, const void*, size_t, size_t, int (*) (const void *, const void *) ); I'm really curious about how they used void pointers. ...

How does Qt implement signals and slots?

Can someone explain to me the basic idea of Qt signals&slots mechanism IMPLEMENTATION? I want to know what all those Q_OBJECT macros do "in plain C++". This question is NOT about signals&slots usage. added: I know that Qt uses moc compiler to transform Qt-C++ in plain C++. But what does moc do? I tried to read "moc_filename.cpp" files b...

Implementation Advice: Binding a button (Click event) to a function, and to another Control too.

I am developing a small C#-winforms program, that has a feature allowing users to add buttons and different controls at run-time. The scenario i am facing is as follows: 1) User adds a button and sets its properties (through a Dialog). 2) User adds a another control (also sets its properties). 3) User chooses the button and choose...

Why use two stacks to make a queue?

I can see the advantage of using two stacks if an array implementation is used since stacks are more easily implemented using arrays than stacks are. But if linked-lists are used, what is the advantage? The act of popping the stack onto the queue increases overhead for both linked-list and array implementations. ...

BST implementation

What's wrong with the following implementation of a binary search tree (BST)? I have been told that it is better to use pointer to a pointer to struct node as an argument in insert function. struct node { int key_value; struct node* left; struct node* right; }; insert(int key, struct node *leaf) { if( leaf == 0 ) { leaf...

python parent class 'wrapping' child-class methods

Hello all, I have the following situation in my python code: class Parent(object): def run(self): print "preparing for run" self.runImpl() print "run done" class Child(Parent): def runImpl(self): print "child running" However, I have several such 'decorators', doing different setup/teardown ste...

Understanding Comet by Example

Its feature is so called "server push", which google wave seems also leverages. Can someone explain this concept by code snippet how it actually works in web application? ...

Implementation of DPLL algorithm in Prolog

I'm trying to apply the simplified algorithm in Prolog, but I'm not a Prolog master. I need it without any mistakes, so I thought you guys might be able to help. What is the implementation of DPLL algorithm in Prolog? ...

JAXB Implementation class parameter return me null

My web services kept prompt me null input after I add in the implementation class. Below is my schema file. <xsd:complexType name="module"> <xsd:annotation> <xsd:appinfo> <jaxb:class name="Module" implClass="packageA.ModuleImpl"/> </xsd:appinfo> </xsd:annotation> <xsd:sequence> <xsd:e...

Simplest C# implementation of A* algorithm?

Hi all, I'm looking for a simple implementation of A* (A star) algorithm in C#. Any pointers? Thanks you. ...

Implementation check list Framework

Suppose iam moving one SP ( or an alter script etc..) from Developement enviornment to QA enviornment . Before migration , i want to check a list of things like , all the tables used in the sp are present , all the functions or sub sp's are present , or in the case of alter script , if any index is present in the column iam trying to cha...