implementation

Implementation question involving implementing an interface

I'm writing a set of collection classes for different types of Trees. I'm doing this as a learning exercise and I'm also hoping it turns out to be something useful. I really want to do this the right way and so I've been reading Effective Java and I've also been looking at the way Joshua Bloch implemented the collection classes by lookin...

Deleting a node from a skip list

I'm having some problems deleting a node from a skip list. I have the following structures: struct Node { int info; Node **link_; Node(int v, int levels) { info = v; link_ = new Node*[levels]; for ( int i = 0; i < levels; ++i ) link_[i] = NULL; } }; struct List { int H; // l...

(C) Implementation tactics for heap allocators?

Where are some good resources for looking at the pros/cons of different ways of implementing heap allocators? Resources touching on efficiency (fragmentation, throughput, etc) are preferred. I am NOT looking for simple code repositories. edit: I'm not really interested in the philosophical grounding of this wiki. As such, I don't reall...

[C++] Write connected components of a graph using Boost Graph

I have an file that is a long list of weighted edges, in the following form node1_id node2_id weight node1_id node3_id weight and so on. So one weighted edge per line. I want to load this file into boost graph and find the connected components in the graph. Each of these connected components is a subgraph. For each of these compon...

How to Implement an Interface that Requires Duplicate Member Names?

I often have to implement some interfaces such as IEnumerable<T> in my code. Each time, when implementing automatically, I encounter the following: public IEnumerator<T> GetEnumerator() { // Code here... } public IEnumerator GetEnumerator1() { // Code here... } Though I have to implement both GetEnumerator() methods, they im...

Languages for implementing decision trees

What would be a good choice of programming language in which to implement a decision tree? The results of the implementation will be for personal use only, so no need to consider ability to publish etc. I have heard that Octave is a good option, can anyone explain why a matrix based language is recommended for implementing decision tree...

Using C++ is a Linked-List implementation without using pointers possible or not?

My question is very simple, can one using C++, implment a link-list data structure without using pointers (next nodes)? To further qualify my question, I'm mean can one create a Linked-List data structure using only class instantiations. A common node definition might be like so: template<typename T> struct node { T t; node<T>* n...

Division by zero: Undefined Behavior or Implementation Defined in C and/or C++ ?

Regarding division by zero, the standards say: C99 6.5.5p5 - The result of the / operator is the quotient from the division of the first operand by the second; the result of the % operator is the remainder. In both operations, if the value of the second operand is zero, the behavior is undefined. C++03 5.6.4 - The binary / opera...

Implementation of ll(k) to ll(1) convertor !

is there any implementation of ll(k) to ll(1) convertor ? ...

Simplest way to match 2d array of keys/strings to search in perl?

Related to my previous question (found here), I want to be able to implement the answers given with a 2 dimensional array, instead of one dimensional. Reference Array row[1][0]: 13, row[1][1]: Sony row[0][0]: 19, row[0][1]: Canon row[2][0]: 25, row[2][1]: HP Search String: Sony's Cyber-shot DSC-S600 End Result: 13 ...

FIFO implementation

While implementing a FIFO I have used the following structure: struct Node { T info_; Node* link_; Node(T info, Node* link=0): info_(info), link_(link) {} }; I think this a well known trick for lots of STL containers (for example for List). Is this a good practice? What it means for compiler when you say that Node has ...

When to use "using [alias = ]class_or_namespace;" in c#?

I saw the following namespace implementation in an article and i really can't get the point why they did so? using sysConfig =System.Configuration ; string connectionString = sysConfig.ConfigurationManager. ConnectionStrings["connectionString"].ConnectionString; I know It can be easily implemented like this, ...

An exception to the "only one implementation" rule ?

While I was reading the accepted answer of this question, I had the following question: Typically, methods are defined in header files (.hpp or whatever), and implementation in source files (.cpp or whatever). One of the main reasons it is bad practice to ever include a "source file" (#include <source_file.cpp>) is that its methods imp...

Implement common behaviour in alternative to abstract base classes?

In C#, I have a class hierarchy with a couple of abstract base classes near the top and a fair number of derived classes. A few these concrete classes have some common properties and methods that are implemented identically. It strikes me as wasteful and so one solution might be to implement this common behaviour in another abstract ba...

Understanding Scrum

I have been working as a .net developer following waterfall model. When working on, say a 12 months project, usually my team follows Analysis, Design, Coding and Testing phases. But when it comes to following Scrum process, I don't really understand How I need to deal with it. Consider a sprint for 4 weeks and our backlog has 10 items, ...

How are closures implemented in Python?

"Learning Python, 4th Ed." mentions that "the enclosing scope variable is looked up when the nested functions are later called.." However, I thought that when a function exits, all of its local references disappear. def makeActions(): acts = [] for i in range(5): # Tries to remember each i acts.append(lambda x: i ** x) #...

Single session in two different domains

Hi Guys, I am proposing a design for my company in integrating 4 systems together and putting it into web. All the 4 systems are independent of each other but I am trying to integrate to have more automation. One of the system is as follows : I want to link my companies website (www.xyz.com) to another website (www.abc.com) with same lo...

How can I optimize my implementation of the "toExponential" algorithm to improve precision?

I feel like my implementation is a bit naive. Take notice of the variables min in max which have a rather small precision of +/- 0.0001. If I raise the precision any further the code is just too slow. Algorithm Code private IDynamic ToExponential(Engine engine, Args args) { var x = engine.Context.ThisBinding.ToNumberPrimitive()...

Where can I find the implementation for std::string

I am looking for the code for the c++ string class. What header is it implemented in? ...

Finding closest neighbour using optimized Levenshtein Algorithm

I recently posted a question about optimizing the algorithm to compute the Levenshtein Distance, and the replies lead me to the Wikipedia article on Levenshtein Distance. The article mentioned that if there is a bound k on the maximum distance a possible result can be from the given query, then the running time can be reduced from O(mn)...