Is there a good resource to get run times for standard API functions? It's somewhat confusing when trying to optimize your program. I know Java isn't made to be particularly speedy but I can't seem to find much info on this at all.
Example Problem:
If I am looking for a certain token in a file is it faster to scan each line using string.contains(...) or to bring in say 100 or so lines putting them to a local string them performing contains on that chunk.
usually, symbolic functions return vectors for vector inputs:
syms('x');
f=x*2;
subs(f,[1 2 3])
outputs: [2 4 6]
but doing
f=sym('0');
subs(f,[1 2 3]);
outputs: 0
and not: [0 0 0]
so basically, my questions is how do I make f behave as a "normal" symbolic function.
I can do something ugly like f=x-x to create a function that always returns zero, but is there a prettier way?
- (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.
im using netbeans to code a web application with symfony.
it seems that netbeans doesnt support symfony in auto completion.
could one fix this problem.
cause i want to be able to click on symfony's functions and get to the source, eg helper function and model methods and classes.
Hello.
In my program, I need to make use of an ElementTree object in various functions in my program.
More specifically, I am doing this:
tree = etree.parse('somefile.xml')
I am passing this tree around in my program.
I was wondering whether this is a good approach, or can I do this:
Create a global tree (I come from a
C++ background and I know global is
bad)
Create the tree again wherever required.
Or is my approach ok?
I believe the expression T() creates an rvalue (by the Standard)
However the following code compiles (at least on gcc4.0)
class T {... };
int main()
{
T() = T();
}
I know technically this is possible because member functions can be invoked on temporaries and the above is just invoking the operator= on the r-value temporary created from T().
But conceptually this is like assigning a new value to an r-value.
Is there a good reason why this is allowed?
hi,
I'm using Drupal for a website and I can only use jQuery 1.2.7 (not the most recent versions).
I want to fade in / fade out a div element and I'm using mouseover / mouseout functions.
However, this element contains some children and when I move the mouse over it, the mouseout function is triggered, because I'm moving over one of its children.
Since I don't have mouseleave function, how can I solve this issue ?
thanks
I'm writing an emulator for a game and one of the functions is "SendToAll".
How can I check which sockets are still connected?
(The client doesn't send a Logout/Disconnect packet.)
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.
Are there any libraries knocking around that provide any additional general purpose math functions for Javascript? Say things like sums over a range, derivatives, integrals, etc. I can imagine that many things aren't possible, so even libraries that do rough approximations would be interesting.
Thanks!
I have a class definition of the form
class X
{
public:
//class functions
private:
A_type *A;
//other class variables
};
and struct A_type is defined as
struct A_type
{
string s1,s2,s3;
};
Inside the constructor, I allocate appropriate memory for A and try A[0].s1="somestring";
It shows segmentation fault.
Is this kind of declaration invalid, or am I missing something
I found the following code example for Java on RosettaCode:
public static boolean prime(int n) {
return !new String(new char[n]).matches(".?|(..+?)\\1+");
}
I don't know Java in particular but understand all aspects of this snippet except for the regex itself
I have basic to basic-advanced knowledge of Regex as you find it in the built-in PHP functions
How does .?|(..+?)\\1+ match prime numbers?
I'm trying to make sure that my Managed to Unmanaged calls are optimized. Is there a quick way to see by looking at the IL if any non-blittable types have accidentally gotten into my pinvoke calls?
I tried just writing two unmanaged functions in a .dll, one that uses bool (which is non-blittable) and one that uses ints. But I didn't see anything different when looking at the IL to let me know that it was doing something extra to marshal the bool.
In some library I'm using (written in C) its
StorePGM(image, width, height, filename)
char *image;
int width, height;
char *filename;
{
// something something
}
All functions are defined this way. I never seen such function definitions in my life. They seem to be valid to MSVC but when I compile it as C++ it gives errors.
What is it? some kind of old version C?
I found that even modern Python versions (like 3.x) are not able to detect BOM on text files. I would like to know if there is any module that could add this missing feature to Python by replacing the open() and codecs.open() functions for reading and writing text files.
I need to write a recursive function that can add two numbers (x, y), assuming y is not negative. I need to do it using two functions which return x-1 and x+1, and I can't use + or - anywhere in the code. I have no idea how to start, any hints?
I have a service and inside one of the functions i'm creating a domain object and trying to save it.
when it gets to the save part, i get the error
No Hibernate Session bound to thread,
and configuration does not allow
creation of non-transactional one here
What do i need to do in order to save a domain object inside of a service. everything on the internet makes it look like this should just work....
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?
I'm doing a security audit on a fairly large php application and was wondering where I should include my user-input validation.
Should I validate the data, then send the clean data off to the back-end functions or should I rely on each function to do it's own validation? Or even both?
Is there any standard or best-practice for this sort of thing?
Currently the app does both inconsistently and I'll like to make things more consistent.
I was wondering why the Vector variable defined within this self executing javascript function doesn't require a var before it? Is this just some other type of syntax for creating a named function? Does this make it so we can't pass Vector as an argument to other functions?
(function() {
Vector = function(x, y) {
this.x = x;
this.y = y;
return this;
};
//...snip
})()
Hi I have created an extrenal javascript and inserted the path in my site.master with other scripts. However, I can`t access the functions of the file.
What can be the problem? Have I done it right, though I wanted to access it directly from my view?
In the code I am writing I need a foo(int, char*) and a foo(int, int) functions.
If I was coding this in C++ I would use templates. Is there any equivalent for C? Or should I use void pointers? How?
Thanks.
I want certain functions in my application to only be accessible if the current user is an administrator.
How can I determine if the current user is in the local Administrators group using Python on Windows?