Search Results

Search found 9082 results on 364 pages for 'c functions'.

Page 171/364 | < Previous Page | 167 168 169 170 171 172 173 174 175 176 177 178  | Next Page >

  • How to get parallel behavior in Java Script ?

    - by Biswanath
    More or less I want to execute two functions in parallel. One way as I see is doing through SetTimeOut function. I have not completely gone through the ReactiveExentension, although it looks promising but may be overkill for my needs. Is there any framework which supports parallelism ? My use case is trivial, but I would like to know if anybody heavily needed parallelism in Java Script ? Thanks, Biswanath.

    Read the article

  • How can I map a String to a function in Java?

    - by Bears will eat you
    Currently, I have a bunch of Java classes that implement a Processor interface, meaning they all have a processRequest(String key) method. The idea is that each class has a few (say, <10) member Strings, and each of those maps to a method in that class via the processRequest method, like so: class FooProcessor implements Processor { String key1 = "abc"; String key2 = "def"; String key3 = "ghi"; // and so on... String processRequest(String key) { String toReturn = null; if (key1.equals(key)) toReturn = method1(); else if (key2.equals(key)) toReturn = method2(); else if (key3.equals(key)) toReturn = method3(); // and so on... return toReturn; } String method1() { // do stuff } String method2() { // do other stuff } String method3() { // do other other stuff } // and so on... } You get the idea. This was working fine for me, but now I need a runtime-accessible mapping from key to function; not every function actually returns a String (some return void) and I need to dynamically access the return type (using reflection) of each function in each class that there's a key for. I already have a manager that knows about all the keys, but not the mapping from key to function. My first instinct was to replace this mapping using if-else statements with a Map<String, Function>, like I could do in Javascript. But, Java doesn't support first-class functions so I'm out of luck there. I could probably dig up a third-party library that lets me work with first-class functions, but I haven't seen any yet, and I doubt that I need an entire new library. I also thought of putting these String keys into an array and using reflection to invoke the methods by name, but I see two downsides to this method: My keys would have to be named the same as the method - or be named in a particular, consistent way so that it's easy to map them to the method name. This seems WAY slower than the if-else statements I have right now. Efficiency is something of a concern because these methods will tend to get called pretty frequently, and I want to minimize unnecessary overhead. TL; DR: I'm looking for a clean, minimal-overhead way to map a String to some sort of a Function object that I can invoke and call (something like) getReturnType() on. I don't especially mind using a 3rd-party library if it really fits my needs. I also don't mind using reflection, though I would strongly prefer to avoid using reflection every single time I do a method lookup - maybe using some caching strategy that combines the Map with reflection. Thoughts on a good way to get what I want? Cheers!

    Read the article

  • FORTRAN: determine variable type

    - by tibbs
    hello, GOOGLE has yet to find an answer for me, so here goes: In FORTRAN, is there a way to determine the TYPE of a variable? E.G., pass the variable type as an argument in a function, to then be able to call type-specific code with that fuction; eliminating the need to have seperate similar functions for each data type. thanks.

    Read the article

  • Is it possible to format C++ code with VIM?

    - by Werner
    Hi, I am rather new to VIM. I got some source code and this is a mess. At a first sight I would like at least to get a clear and organised view of the code, so I like to get it rightly formatted, I mean indented depending on the depth of the functions and so. I wonder if it can be done with VIM, and otherwise which other commandline tools for that can you recommend. Thanks

    Read the article

  • Is it possible to get a graphical representation of gprof results?

    - by Werner
    Hi, I am interested in getting the profiling of some number crunching program. I compiled it with -g and -pg options and linked it and got it gmon.out. After reading the info (plain text) it looks a bit ugly. I wonder if there are some open source tools for getting a graphical representation of the 10 functions where the program spends the most of the time as well as a flux diagram. Thanks

    Read the article

  • Simple check authentication decorator in Python + Pylons

    - by ensnare
    I'd like to write a simple decorator that I can put above functions in my controller to check authentication and re-direct to the login page if the current user is not authenticated. What is the best way to do this? Where should the decorator go? How should I pass cookie info to the decorator? Sample code is greatly appreciated. Thank you!

    Read the article

  • Why can't I make my parameter like this?

    - by mystify
    - (void)setPropertyValue:(const *void)inValue forID:(UInt32)propertyID { } The compiler doesn't like the const *void, for some reason. When I have that, it says: error: expected ')' before 'void' When I make the parameter like (UInt32)foo there is no problem. Does const *void only work in functions? I need a parameter which can be a "pointer to anything" like UInt32, Float64, etc.

    Read the article

  • Why does string::find return size_type and not an iterator?

    - by dehmann
    In C++, why does string::find return size_type and not an iterator? It would make sense because functions like string::replace or string::insert take iterators as input, so you could find some character and immediately pass the returned iterator to replace, etc. Also, std::find returns an iterator -- why is std::string::find different?

    Read the article

  • How can I check for unused import in many Python files?

    - by Thierry Lam
    I remember when I was developing in C++ or Java, the compiler usually complains for unused methods, functions or imports. In my Django project, I have a bunch of Python files which have gone through a number of iterations. Some of those files have a few lines of import statement at the top of the page and some of those imports are not used anymore. Is there a way to locate those unused imports besides eyeballing each one of them in each file? All my imports are explicit, I don't usually write from blah import *

    Read the article

  • Receiving data from a USB device in C or C++

    - by Midas
    It starts to bore me that I always have to ask questions about trifles. I simply need a list of all plugged in USB devices and have the user select one to let the console application receive any data the USB device sends. I can then start playing around with the data in my program. I don't want to use library's, only standard C++ functions, and the program should work in Windows 98.

    Read the article

  • managing IB objects without iboutlets

    - by palominoz
    i have got 24 buttons in my project.I need to manage them but I don't want to get my MainViewController polluted by 24 declarations of pointers, properties & synthesizes. i was thinking about using buttonPushed functions and do it like: -(IBAction)buttonPushed:(id)sender{ UIbutton *button=sender; [buttons addObjectAtIndex:[sender tag]]; } my question is:is sender a pointer to the IBObject?

    Read the article

  • Does F# have an equivalent to Haskell's take?

    - by McMuttons
    In Haskell, there is a function "take n list" which returns the first n elements from a list. For example "sum (take 3 xs)" sums up the first three elements in the list xs. Does F# have an equivalent? I expected it to be one of the List-functions, but I can't spot anything that seems to match.

    Read the article

  • C++ int vector to c#

    - by Stefan Koenen
    I'm doing a C# project and I want to call next_permutation from the algorithm library in C++. I found the way to call c++ functions in c# but i dont know how to get vectors from c++ and use it in c# (cause next_permutation require a int vector...) this is what I'm trying at the moment: extern void NextPermutation(vector<int>& permutation) { next_permutation (permutation.begin(),permutation.end()); } [DllImport("PEDLL.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void NextPermutation(IntPtr test);

    Read the article

  • Any way to detect SMS to E-Mail Gateways?

    - by Paul
    I want to create a PHP app that can send text messages. There are different gateways for different email carriers. Is there any library I could use that would be able to lookup or detect which gateway to use just by passing the phone number into it? This way I can take whatever email address I get out and use PHP's email functions to send a message. Thanks in advance!

    Read the article

  • exclude the folders - url rewrite in htaccess

    - by aquagirl
    rewriteCond %{REQUEST_URI} ^(ajax|css|functions|image_viewer|images|img|include|fancybox|jquery|jscript|json)$ - [L] RewriteRule ^(.[^/])/(.[^/])/(.+[^/]) ?program=$1&usertype=$2&username=$3 [NC] could you please help me find what is wrong in this.. ? I need to exclude some folders from url rewriting. i tried with the solution given here.. but still i am getting some errors.. http://www.idxsync.com/sbaor/Search/Agent/zz please help me

    Read the article

< Previous Page | 167 168 169 170 171 172 173 174 175 176 177 178  | Next Page >