# klayAlloy

Member

57

150 Neutral

• Rank
Member

2. ## Billion word sort

Also, doing it this way, in a search, how would I return the position of the value searched for? I'm not sure it's possible.
3. ## Billion word sort

Thank you all for the replies. I had a few questions about the radix sort. Quote: Shannon Barber: Create a function that takes the 5 character string and encodes it to a 30 bit string. Encode the 42 possibilities to a 6 bit string and or-shift the 5 of them together into 1 30 bit number. Make a single 1GB file and zero it. Read in the first string, encode it and add 1 to the byte position in the 1GB file. Do this for all 1billion numbers. If the numbers are evenly distributed this will work without issue. My understanding is that each 5 char string will end up representing a unique byte in the 1gb file. "AAAAA" -> byte 1, "abfgD" -> byte n. Then, when I come across that value in the original data file, and encode it, it basically increases the counter value being stored in the final file. Am I getting this right?
4. ## Billion word sort

I have this project for school where I need to write a sorting algorithm that will work for one billion 5 character strings [a-u, A-U]. I'm not looking for answers, more just ideas some of you might have. It's supposed to be done in C++ on a single computer with a single hard drive. And the algorithm needs to be black boxed. It should work with 100, 1000, 10000, etcetera 5 character strings. It needs to figure it out at runtime on it's own. After it's sorted I need to search for 2 strings hidden in the billion strings. What i'm planning now is a merge sort of some kind. Before I start reading from the file, i'll create a bunch of files on the hard drive which will be responsible for holding strings starting with a certain character. eg. filenames[a.dat, b.dat, c.dat, ... G.dat, H.dat,...]. As I pull the data out of the main file, i'll throw it into the appropriate temp file...the string abHgu would go to the a.dat file. Once I reach the end of the main file, i'll go and sort each individual file and then merge them back into one file. When i'm reading the initial data, i'll probably open a couple hundred streams (you can open 509 simultaneously in vs2005...3 are reserved for cin, cout, cerr) and have each one read like every nth string. Anyway, any hints or ideas people might like to share, or point out anything that might push me in a better direction or point something out I'm getting wrong, would be very much appreciated.
5. ## std::string

zahlman: Thank you for the response. I guess I still have a ways to go before I get streams down. Slowly, very slowly, I'm learning.
6. ## std::string

I think I found the answer: std::string temp; std::getline(std::cin, temp)
7. ## std::string

I'm need to prompt the user for a sentence and store the sentence in a std::string. I'm then going to seperate each word out of the sentence into a std::vector of strings. I tried using std::cin, but the stream closes after the first space between words. Any help on how to approach this would be great?
8. ## casting std::string

Thank you for the quick responses. It makes sense now why it wasn't working. I currently haven't used the boost library before, but it is something i'll look into. I'll use the stringstream method for now. Thanks again for all the help.
9. ## casting std::string

I'm using the this following piece of code: int num =0; std::string myString; num = (int)myString.c_str(); to turn an std::string into an int value to be stored elsewhere. It doesn't work the same everytime though. num is given a different value for the same string. Why is that? Would I better off to write my own string to int function?
10. ## class/list issues

Zahlman: your response to the post was great. It pointed a few things out to me that i've been having some trouble with. Thank you.
11. ## You Guys Are Jerks, Friendly Jerks

oluseyi: beautiful!!

anyone?
13. ## [java] A good java book

I know everyone has their favorite authors and publishers, but i'd really like to get some opinions on what book to buy. I've been using C++ for about 2 years and i've learned the basics of C# over 3 months. For personal reasons, I need to learn Java (dropping C# for now...but will pick up later) in the next 2 and a half months. These are the books in question: -Just Java 2 -Murach's Beginning Java 2 -Core Java 2, Vol 2 -Professional Java 2 The first 2 seem to introduce you to java and oop and also show you a little bit more of the advanced techniques. The last two don't focus on learning java, but go in depth into the more advanced parts of java. I need one book for now and in a few months, pick up a more advanced book. Any suggestions would be great.
14. ## Windows GDI+ help

Thank you. I'll go ahead and try it and see if it helps.
15. ## Windows GDI+ help

I can't get the flicker out of my program. All the project is right now is a side scrolling starfield (250 pixels) and a half dozen circles. I've been trying everything to get the flicker to go away. I'm using C++ and the program is set up so that I render a bitmap backbuffer when the WM_PAINT message is sent. It simply calls BitBlt() using the window dc as the destination and my buffer as the source. In my update function (which gets called each frame), I clear out the stars and the circles, update the stars, then I call a render function which renders everything to the buffer. Right after that function call I call InvalidateRect(). I think that that is where my problem is. Could anybody please help me it. It would be very much appreciated. Thank you.