Neighbour: 'OK, so your moggy can do tech support - my pooch drove me back from the bar last night - much more useful", Me: "Your motor seems to be parked up neatly, can't be a bitch then", (female developers, have at me all you want:)
I am required to convert some C++ codes to C and I am having some problems regarding the STL container. In the original C++ code, set container is used as in set< pair<int, int>, sortMapped> mySet; where sortMapped is a custom comparator to "sort" the entry by mapped value instead of ...
@MartinJames Did you shatter the glass front before you lost it?
One of my friends took the case off his phone for the first time in ages, since we convinced him it looks sexier that way, and within 20 minutes, he shattered the screen.
@MartinJames At least you didn't: Hey I have this really off topic question about JQuery. Here's my SO question link. Can anyone help me?!?!?! for your first time posting here.
@R.MartinhoFernandes US to berlin was about 8-900 USD
@R.MartinhoFernandes Would you like to be stuffed in a box and sit in the cargo bay? You could probably find cheaper then. Maybe ship yourself to yourself.
@MartinJames then you did something wrong. it should always work with floating point. are you perhaps suffering from misperception that floats are sort of fuzzy?
@Borgleader I wouldn't have answered that question, honestly, since it seems like one of those repwhore like questions. But maybe that's why I'm still at 1.5k rep myself.
@MohamedAhmedNabil A loop executes one section of code repeatedly. A switch has a number of sections of code that could be executed, and for any given execution selects one of those to actually execute. The two are often combined -- e.g., a loop to read data, with a switch inside to select how to process each datum you read.
How do I check if a string is present in a bigger string of length of 100,000 characters in C++ or Java?
I know a method str.find("sub_string"); but it can't handle such a big string.
The max execution time is 1 sec.
Thanks
> If a constexpr function or constructor is called with arguments which aren't constant expressions, the call behaves as if the function were not constexpr, and the resulting value is not a constant expression. Likewise, if the expression in the return statement of a constexpr function does not evaluate to a constant expression for a particular invocation, the result is not a constant expression.
^ What's the use? Could constexpr instead lead to more ILP?
@Drise With if/else, you have to use else to keep from executing one if after another. With switch, you use break to do that. else is one character shorter, but that's hardly what I'd call a major consideration.
Why is this an SO question? Just write code that does what you need using whatever string search algorithm you like. As asked, this is way too vague to answer because it doesn't give us nearly enough information to choose the appropriate algorithm. (Does the substring change from search to search? Does the string? Is the string evenly distributed characters? Does the substring contain rare inner substrings? And so on.) — David Schwartz5 mins ago
@Rapptz In case I was wrong. VERY WRONG. Like im not probably gonna switch because @MooingDuck didnt find it better and I trust him, as well as it being hard. And because he asked why I wanted to switch
http://efesx.com/2009/12/01/public-operator-new-and-private-operator-delete/
In this article i read that this code should give an error:
#include <cstdlib>
struct Try {
Try () { /* o/ */ }
void *operator new (size_t size) {
return malloc(size);
}
...
I have a question... When I have a vector of pointers which point to instances of a class (free store), how do I effectively remove elements (both the pointers which are formal members, and the instances which are pointed to) from it? I remove the pointer, and then delete the instance that is in free store, is that correct?
@MohamedAhmedNabil Windows GUI makes it easy to explore all your options. Linux GUIs aren't usually as extensive, requiring command line work, which is a PITA.
@StackedCrooked No, I'd say that looks semi-reasonable. You probably are getting better than normal performance by writing then immediately searching though -- good chance the whole string is in the cache when you're searching it this way.
@Bane: unrelated: mouseover a message and click the arrow on the right to "reply" makes conversations easier to follow. Also, in case you don't know, up arrow to edit last message.
@Xeo, yeah, I figured that I want to have a vector of pointers because vector <ClassA> stuff; returned an error (this was a forward declaration in a .hpp file that didn't know anything about ClassA)
@MohamedAhmedNabil Linux is a clone of Unix (but has taken over the market to the point that for all practical purposes, it now is Unix). The others (Ubuntu, Arch, Gentoo, etc.) are distributions of Linux. I.e., most of what's included in Linux is a collection of separate projects, and somebody has to select what to include and what not so. The result is a distribution.
Yay. I learned a cool trick today. So I have a number who's binary pattern is 110011011 and I want to toggle the MSB 1 bit, it can be done easily like this using GCC:
#include <stdio.h>
#define clz(x) __builtin_clz(x)
int main()
{
int i = 411; /* 110011011 */
if( i != 0 )
i ^= (1 << (sizeof(i)*8 - clz(i))-1);
/* i is now 10011011 */
printf("i = %d\n", i);
return(0);
}
If a virtual machine runs a program then how does it prevent that if the program crashes, the virtual machine doesn't crash with it? E.g. null pointer dereference by the program shouldn't crash the VBox. Does it emulate the CPU or something like that?
@Xeo There is a huge error message when I use vector <ClassA> ClassesA;. And just for the record, I do have using std::vector in the beginning of the .hpp...