FAQ Database Discussion Community


interface listener in fragment

java,android,android-fragments,implementation
sorry for my question, I guess it's pretty simple. I have a Fragment that needs to implements an interface listener. package com.tumta.henrique.teste; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import com.tumta.henrique.teste.ConsultaEntidades.*; import java.util.List; /** * A simple {@link Fragment}...

Calling on an implemented method automatically?

java,oop,implementation
I was curious about how the implements keyword works, and I was hoping someone could explain to me, where does the implemented method get called on? For example let's say I have a class that implements ActionListener. It now implements the public void actionPerformed(ActionEvent e) { } method. I have...

How to implement a class that uses a template doubly linked list?

c++,templates,data-structures,implementation,doubly-linked-list
I'm sorry if my question is so vague, I don't know how else to word it. Basically, lets say I have implemented a doubly linked class with templates and now I want to use that class elsewhere. consider doubly is the doubly linked class and is the typename. The nodes...

Why I can't find any native method in printIn() implementation?

java,io,implementation
I walk through the program of below statement: System.out.println("foo"); In my understanding, all functionality Java provides should ultimately call system specific API but I can only see, in println() implementation, calling ordinary methods in Writer/BufferWriter/PrintStream. Where do I get wrong?...

Using machine learning to make a computer learn calculus

machine-learning,integration,neural-network,implementation,calculus
Are there any known approaches of making a machine learn calculus? I've learnt that it is quite simple to teach calculating derivatives because it is possiblen to implement an algorithm. Meanwhile, an implementation of integration is possible but is rarely or never fully implemented due to the algorithmical complexity. I...

Calculation of euler phi function

algorithm,math,implementation
int phi (int n) { int result = n; for (int i=2; i*i<=n; ++i) if (n % i == 0) { while (n % i == 0) n /= i; result -= result / i; } if (n > 1) result -= result / n; return result; } I saw...

Separate implementation and declaration with templates and nested types in C++

c++,templates,nested,implementation
If I keep the function Find() inlined, then the program compiles. Otherwise, as shown below, it does not compile. Is it possible to separate the declaration and implementation of such: ////////////////////////////////////////////////////////////////////////// template <class T> class MyClass { public: struct MyStruct { int id; T value; }; MyStruct *Find(int id); private:...

Where can I find an existing implementation of sprintf? [closed]

c++,printf,implementation,glibc
I need to customize c++ sprintf function, after step into sprintf, i got _cfltcvt_l, but there isn't _cfltcvt_l source code in visual studio. I did the same thing in g++, it lead me to __mingw_vsprintf function, but i don't know where __mingw_vsprintf is. I know that glibc is one of...

Definitions of saddle points, nodes and edges

algorithm,image-processing,implementation
I am working on some algorithm implementation, however being new to image processing, I have some questions about some of the definitions used. They(in the paper) keep on mentioning a node without prior definition, this means a truepoint with 2 other trueneighbors(out of 8). Am I right ? (this is...

Create List [x-n, x-n+1,…,x,x+1,x+2,…x+n] in Java

java,implementation
I'd like to get a method returning ArrayList as following: int x = ...; int n = ...; List<Integer> list = getList(x,n); System.out.println(list.size()) // => 2n+1 int i = ...; for(int elem : list){ System.out.println(elem); } // => x-n, x-n+1, x-n+2,..., x-1, x, x+1,..., x+n For instance, getList(3,1) // =>...

V8 JavaScript engine implementation languages

javascript,c++,google-chrome,implementation
Looking from the wiki articale on V8 Javascript engine it says that it is written in C++ and JavaScript itself but what does that exactly mean?I mean What is written in C++ and what is in Javascript? And how these 2 languages work with each other? V8 JavaScript Engine Developer(s)...

Having a type defined in C API how to associate it with C++ class in a namespace?

c++,c,implementation
So we have in CAPI.h (and no implementation) struct Message; typedef struct Message Message; And we have a CPP_API.h with namespace Bla { struct Message {}; } How to associate Bla::Message with Message defined in C API? In other words to make Bla::Message be an implementation of Message defined in...

What are the advantages of explicit interface implementation in C#? [duplicate]

c#,inheritance,interface,implementation
This question already has an answer here: C# Interfaces. Implicit implementation versus Explicit implementation 11 answers C# supports built-in mechanism for differentiating methods that have the same names. Here is a simple example below shows how it works: interface IVehicle{ //identify vehicle by model, make, year void IdentifySelf(); }...

PHP-Unit Tests: how to implement a TYPO3 Extbase object interface

interface,phpunit,typo3,implementation,extbase
I have some problems with the PHP UnitTests for my Controller: this is the function in my controller code that has to be tested public function newAction(\ReRe\Rere\Domain\Model\Fach $newFach = NULL) { // Holt die übergebene Modulnummer if ($this->request->hasArgument('modul')) { // Holt das Modul-Objekt aus dem Repository $modul = $this->modulRepository->findByUid($this->request->getArgument('modul')); }...

Board Game Implementation in Java

java,implementation,class-diagram
First of all, I am not sure whether it is allowed to ask this kind of question. So I am trying to create a board game and I was stuck at the implementation of generating valid moves for Piece. Here is the extract of the class diagram. You can think...

Converting binary decision diagram to truth table

algorithm,data-structures,implementation,boolean-logic,binary-decision-diagram
Given a binary decision diagram, how do I convert it into a truth table? What is the exact algorithm for it ? I have been trying this for a long time. Here is an example which one can follow: Source: Wikipedia. (The dotted edges represent 0; solid edges, 1.)...

kNN state-of-the-art implementation

machine-learning,implementation,knn
I am looking for a kNN implementation package. This package should: deal with multi-label problem give a detailed output, what are those k nearest neiboneighbors points that classify the test point. Implement all kinds of distance metrics. Implement all kind of instance weighting. So far, I have not found one...

Implementation conflicts between protocols

swift,oop,inheritance,protocols,implementation
I've stumbled upon an issue, and I can not figure out how am I going to solve it. Let's suppose we have a base class (that may comes from FrameworkA), with a property named subject: public class MyClass { public var subject: String } And we have a protocol (that...

If I extend an abstract class, that is implementing an interface, do I need to rewrite the methods?

java,interface,abstract-class,implementation
I have an interface with several methods. I then have an abstract class that defines some of those methods, but also leaves some of the methods abstract. Now I have a class that extends the abstract class. Do I need to write all the methods from the original interface and...

C++ nested class - moving implementation to different file

c++,implementation,pimpl-idiom
I'm trying to learn how to use the PIMPL idiom because it reduces compilation dependencies, which I've heard is recommended. So I have code that essentially looks like this. Foo.h class Foo { public: Foo(); private: class FooImpl; std::unique_ptr<FooImpl> impl; } Foo.cpp Foo::Foo(): impl(new FooImpl) { } class Foo::FooImpl {...

How to specify what “list” the product was added to cart from? Enhanced Ecommerce

javascript,google-analytics,e-commerce,implementation,product
Trying to implement Google Analytics Enhanced Ecommerce tracking for my website. How to specify what "list" the product was added to cart from? Here is the standard tracking code for adding the product to basket: // Called when a product is added to a shopping cart. function addToCart(product) { ga('ec:addProduct',...

Implementation of mergesort

c++,implementation,mergesort
I'm writing a mergesort on list (don't look at the functions, I still build them). The problem is following: compilator can't read an induction of merge_sort, I don't know why. I'd like to ask you for help. Below is shown the code. #include <iostream> #include <cstdlib> #include <iomanip> #include <time.h>...

Codility Brackets challenge performance issue

java,performance,algorithm,implementation
Trying out a simple codility challenge (check that a string of {} characters is well-formed) I have become stumbled by the fact that my solution has a terrible performance score and even times out on some of their test cases. The specification is "return 1 if well-formed, 0 otherwise": class...

Python Trie implementation why create temporary variable [closed]

python,algorithm,data-structures,implementation,trie
I looked at this code: >>> _end = '_end_' >>> >>> def make_trie(*words): ... root = dict() ... for word in words: ... current_dict = root ... for letter in word: ... current_dict = current_dict.setdefault(letter, {}) ... current_dict = current_dict.setdefault(_end, _end) ... return root ... >>> make_trie('foo', 'bar', 'baz', 'barz')...

How java assign value to final attribute

java,arrays,implementation
We know that an Array object (array) has a length attribute and it was declared in Java as: public final int length; It was declared as final thus no accessor is needed and we cannot change the value of length unless a new array is created. My question is: I...

How is git checkout implemented?

git,implementation
When running git checkout, the mergebase of the old HEAD and the new HEAD can be arbitrarily far back. The naïve implementation would be to linearly apply each diff, yet the operation runs instantly. I have a hunch it might be implemented with something kind of skiplisty for intermediate diff...