If one writes in C or C++
int x = 1 << 2;
Is it guaranteed regardless of platform that x is now 4? I was thinking it would have to be, but a friend was claiming that on some platforms the value...
Type: Posts; User: Aisthesis
If one writes in C or C++
int x = 1 << 2;
Is it guaranteed regardless of platform that x is now 4? I was thinking it would have to be, but a friend was claiming that on some platforms the value...
I'm trying to use Boost for unit testing on Xcode and am having trouble getting things to link properly.
I put the boost download into the directory (on my Mac with Lion) /usr/local/boost_1_49_0....
here's my current code for hasher() and hasher_update():
size_t phantom::xor_hasher(const std::string &s) {
size_t len = s.size();
assert (len > 0);
unsigned int result = 0U;
...
substituting operator[] for at() in all character retrievals from string, here's a sample run:
first string and pattern:
div method: 1.679
xor method with global array: 3.087
second string...
the .at() gets eliminated in the array version (which speeds it up to double the time of the div method), at least for the array. and all other instances (with the string) are identical for all 3...
so it compiles but always prints "Failed to insert uniform"?
if so, maybe set a breakpoint at the this->uniforms.insert(pair...); line and see if the debugger tells you anything useful.
if it...
the only part i didn't test for was not having at least 7 bits in common with any neighbor. i did get uniform distribution and just used std::random_shuffle() after all and left it at that.
...
phantom, using your exact code (deleting superfluous lines from my original that have no relevance for xor and running it through a global array rather than the PrimeArray class), it improves (about...
uh... phantom, aside from some names and deleting unused code, the only thing i really changed was making the keys array into a class so that i could use the constructor to make it fit the desired...
i'm not sure exactly what the program is doing if you code it like that, but you haven't allocated any memory for the pointers (are they perhaps all pointing to NULL prior to being allocated?).
...
oddly enough, phantom, the xor implementation seems slower by almost a factor of 3 than the division method. On my laptop, I get somewhere around 1.8 with division and 4.5 with XOR on the first...
i think elysia is talking about what i call absolute and relative paths. absolute (explicit) means that you spell out the entire path all the way from the root (e.g., in Windows, c:\Users\...)...
just looking at a few entries in it, the distribution looks reasonable to me.
first ignoring the (easy) issue of randomizing the order of the keys[] array, here's the way i'm initially populating it:
i implement it as a simple class:
class PrimeArray {
private:...
that makes sense--i might still do it the long way just for practice with various hashing methods.
do the primes i was suggesting sound reasonable for the contents of the array prior to shuffling?
is random bit distribution the only reason that we want keys[i] to be prime?
how's this as method for generating keys[]:
1) for the highest order bits, use a deterministic process to define slots...
very interesting. if we restrict ourselves to small ASCII keys could also be only 128 + 128, right?
and the primes in keys all just need to be bigger than 256, correct? and maybe also a minimum...
so the program is supposed to split up the string "Sam Harris" into "Sam" and "Harris" and print out accordingly?
if so, while i haven't really worked with istringstream objects, getline() should...
a global variable isn't defined inside a class, whereas a static variable is. a global variable dies with its file, whereas a static variable dies when no instance of the class in which it is defined...
just by running it on some big strings with different kinds of structures, i came up with an empirically
"optimal" modulus of something like 1511, although on my minimal sample sets i saw very...
This is an algorithm for finding a pattern substring in a text string. I got it from Skiena, Design Algorithm Manual, 2008, pp. 91f. It works by hashing the substring and starts getting nice results...
unsigned power_of_two(unsigned i) {
while(i & (i-1))
i &= i-1;
return i;
}
very nice!
i do think the modified brewbuck solution will be faster (fewer iterations) if i is often a...
visual studio 2010?
any way to look at source code?
cool, thanks! as long as there's a good and at least fairly widely accepted implementation out there, the best way to learn is probably just to study that.
so... where does that leave us? i have no desire to re-invent the wheel but would like to have a nice hash_map and hash_set
those linked to look very nicely done